Get /connect pagination working (for real in prod I hope) (#507)

This commit is contained in:
Ben Halpern 2018-06-27 18:47:06 -04:00 committed by GitHub
parent aaba866b87
commit b8d2c0033e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 10 deletions

View file

@ -76,7 +76,7 @@ export function getChannels(query,retrievalID, props, paginationNumber, successC
const client = algoliasearch(props.algoliaId, props.algoliaKey);
const index = client.initIndex(props.algoliaIndex);
index.search(query,{
hitsPerPage: 24,
hitsPerPage: 30 + paginationNumber,
page: paginationNumber
})
.then(function(content) {

View file

@ -89,7 +89,7 @@ const Channels = ({ activeChannelId,
});
let channelsListFooter = ""
if (channels.length === 30) {
channelsListFooter = <div className="chatchannels__channelslistfooter">You may connect with any dev you mutually follow. Use the filter to discover all your channels.</div>
channelsListFooter = <div className="chatchannels__channelslistfooter">...</div>
}
let topNotice = ''
if (expanded &&

View file

@ -174,16 +174,17 @@ export default class Chat extends Component {
}
loadPaginatedChannels = (channels) => {
const currentChannelIds = this.state.chatChannels.map((channel, index) => {
const currentChannels = this.state.chatChannels;
const currentChannelIds = currentChannels.map((channel, index) => {
return channel.id
})
let newChannels = this.state.chatChannels
let newChannels = currentChannels
channels.forEach((channel, index) => {
if (!currentChannelIds.includes(channel.id)) {
newChannels.push(channel)
}
});
if (this.state.channelPaginationNum === 10) {
if (currentChannels.length === newChannels.length && this.state.channelPaginationNum > 3) {
return
}
this.setState({
@ -294,13 +295,12 @@ export default class Chat extends Component {
};
handleChannelScroll = e => {
if (this.state.fetchingPaginatedChannels || this.state.chatChannels.length < 20) {
if (this.state.fetchingPaginatedChannels || this.state.chatChannels.length < 30) {
return
}
this.setState({fetchingPaginatedChannels: true})
const target = e.target;
if((target.scrollTop + target.offsetHeight + 600) > target.scrollHeight)
{
if((target.scrollTop + target.offsetHeight + 1800) > target.scrollHeight) {
this.setState({fetchingPaginatedChannels: true})
getChannels(
this.state.filterQuery,
this.state.activeChannelId,
@ -456,7 +456,6 @@ export default class Chat extends Component {
setActiveContent = response => {
let newActiveContent = this.state.activeContent
newActiveContent[this.state.activeChannelId] = response
console.log(newActiveContent)
this.setState({activeContent: newActiveContent});
setTimeout(function() {
document.getElementById("chat_activecontent").scrollTop = 0;