diff options
| author | jasper <jasper92341@hotmail.com> | 2019-02-27 17:45:08 -0800 |
|---|---|---|
| committer | jasper <jasper92341@hotmail.com> | 2019-02-27 17:45:08 -0800 |
| commit | 9aec49bacb033cdcc118f821706c419d384bf5fe (patch) | |
| tree | 983e8ab98d4c780e6d30436ced83e05dba76c43e /src/modules/statuses.js | |
| parent | d5348c13ff542ae77c3c87e381dc54f5e7619acc (diff) | |
Fetch activites by last id
Diffstat (limited to 'src/modules/statuses.js')
| -rw-r--r-- | src/modules/statuses.js | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/modules/statuses.js b/src/modules/statuses.js index 826b544c..4002f282 100644 --- a/src/modules/statuses.js +++ b/src/modules/statuses.js @@ -10,6 +10,7 @@ const emptyTl = (userId = 0) => ({ visibleStatusesObject: {}, newStatusCount: 0, maxId: 0, + minId: 0, minVisibleId: 0, loading: false, followers: [], @@ -117,11 +118,16 @@ const addNewStatuses = (state, { statuses, showImmediately = false, timeline, us const timelineObject = state.timelines[timeline] const maxNew = statuses.length > 0 ? maxBy(statuses, 'id').id : 0 - const older = timeline && maxNew < timelineObject.maxId + const minNew = statuses.length > 0 ? minBy(statuses, 'id').id : 0 + const newer = timeline && maxNew > timelineObject.maxId && statuses.length > 0 + const older = timeline && (minNew < timelineObject.minId || timelineObject.minId === 0) && statuses.length > 0 - if (timeline && !noIdUpdate && statuses.length > 0 && !older) { + if (!noIdUpdate && newer) { timelineObject.maxId = maxNew } + if (!noIdUpdate && older) { + timelineObject.minId = minNew + } // This makes sure that user timeline won't get data meant for other // user. I.e. opening different user profiles makes request which could @@ -255,13 +261,8 @@ const addNewStatuses = (state, { statuses, showImmediately = false, timeline, us processor(status) }) - // Keep the visible statuses sorted - if (timeline) { - sortTimeline(timelineObject) - if ((older || timelineObject.minVisibleId <= 0) && statuses.length > 0) { - timelineObject.minVisibleId = minBy(statuses, 'id').id - } - } + // Keep the visible statuses sorted + if (timeline) sortTimeline(timelineObject) } const addNewNotifications = (state, { dispatch, notifications, older, visibleNotificationTypes }) => { |
