Get /connect pagination working (for real in prod I hope) (#507)
This commit is contained in:
parent
aaba866b87
commit
b8d2c0033e
3 changed files with 9 additions and 10 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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 &&
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue