From c50256d25c47110119ea3386050040c916f2cf83 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Sun, 19 Feb 2017 21:37:04 +0100 Subject: Fix infinite scrolling breaking after navigation --- app/assets/javascripts/components/reducers/notifications.jsx | 5 ++++- app/assets/javascripts/components/reducers/timelines.jsx | 6 +++++- 2 files changed, 9 insertions(+), 2 deletions(-) (limited to 'app/assets/javascripts/components/reducers') diff --git a/app/assets/javascripts/components/reducers/notifications.jsx b/app/assets/javascripts/components/reducers/notifications.jsx index 4a7af8856..968eae9f6 100644 --- a/app/assets/javascripts/components/reducers/notifications.jsx +++ b/app/assets/javascripts/components/reducers/notifications.jsx @@ -37,9 +37,12 @@ const normalizeNotifications = (state, notifications, next) => { items = items.set(i, notificationToMap(n)); }); + if (state.get('next') === null) { + state = state.set('next', next); + } + return state .update('items', list => loaded ? list.unshift(...items) : list.push(...items)) - .set('next', next) .set('loaded', true) .set('isLoading', false); }; diff --git a/app/assets/javascripts/components/reducers/timelines.jsx b/app/assets/javascripts/components/reducers/timelines.jsx index 1c71d822d..2dbced7ae 100644 --- a/app/assets/javascripts/components/reducers/timelines.jsx +++ b/app/assets/javascripts/components/reducers/timelines.jsx @@ -101,7 +101,10 @@ const normalizeTimeline = (state, timeline, statuses, next) => { state = state.setIn([timeline, 'loaded'], true); state = state.setIn([timeline, 'isLoading'], false); - state = state.setIn([timeline, 'next'], next); + + if (state.getIn([timeline, 'next']) === null) { + state = state.setIn([timeline, 'next'], next); + } return state.updateIn([timeline, 'items'], Immutable.List(), list => (loaded ? list.unshift(...ids) : ids)); }; @@ -237,6 +240,7 @@ const resetTimeline = (state, timeline, id) => { .set('id', id) .set('isLoading', true) .set('loaded', false) + .set('next', null) .update('items', list => list.clear())); } else { state = state.setIn([timeline, 'isLoading'], true); -- cgit