aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorShpuld Shpludson <shp@cock.li>2019-03-07 05:06:43 +0000
committerShpuld Shpludson <shp@cock.li>2019-03-07 05:06:43 +0000
commitc44f0a9bde08c50598207494b121ae4bdf1f0fb1 (patch)
tree1847fa78707d800e28997bd8828327cf5c890838 /src
parent423e1b3b125f346864f12b591faf259abc922930 (diff)
parent81e89fed3d6cc247346611e1b58aae9d87667934 (diff)
Merge branch 'fix/fetch-activities-by-last-id' into 'develop'
#406 Fetch activities by last id See merge request pleroma/pleroma-fe!621
Diffstat (limited to 'src')
-rw-r--r--src/modules/statuses.js15
-rw-r--r--src/services/timeline_fetcher/timeline_fetcher.service.js2
2 files changed, 10 insertions, 7 deletions
diff --git a/src/modules/statuses.js b/src/modules/statuses.js
index 826b544c..96a3549d 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,12 +261,9 @@ const addNewStatuses = (state, { statuses, showImmediately = false, timeline, us
processor(status)
})
- // Keep the visible statuses sorted
+ // Keep the visible statuses sorted
if (timeline) {
sortTimeline(timelineObject)
- if ((older || timelineObject.minVisibleId <= 0) && statuses.length > 0) {
- timelineObject.minVisibleId = minBy(statuses, 'id').id
- }
}
}
diff --git a/src/services/timeline_fetcher/timeline_fetcher.service.js b/src/services/timeline_fetcher/timeline_fetcher.service.js
index 64f8f468..6f99616f 100644
--- a/src/services/timeline_fetcher/timeline_fetcher.service.js
+++ b/src/services/timeline_fetcher/timeline_fetcher.service.js
@@ -21,7 +21,7 @@ const fetchAndUpdate = ({store, credentials, timeline = 'friends', older = false
const timelineData = rootState.statuses.timelines[camelCase(timeline)]
if (older) {
- args['until'] = until || timelineData.minVisibleId
+ args['until'] = until || timelineData.minId
} else {
args['since'] = timelineData.maxId
}