about summary refs log tree commit diff
path: root/app/javascript/flavours/glitch/actions/timelines.js
diff options
context:
space:
mode:
authorDavid Yip <yipdw@member.fsf.org>2018-01-18 10:25:37 -0600
committerDavid Yip <yipdw@member.fsf.org>2018-01-18 10:25:37 -0600
commitbcd86404daf90b120eeb339f0cfeee7a6c25dd94 (patch)
treeea89d9c5f9936678ef9cd05e879dc594d9c390a0 /app/javascript/flavours/glitch/actions/timelines.js
parent1964a0f9415de1082c9948cd7dd02ededa36af7b (diff)
Port 7badad7797b487b411a2ab34e0f7413741974bb4 to glitch frontend
Diffstat (limited to 'app/javascript/flavours/glitch/actions/timelines.js')
-rw-r--r--app/javascript/flavours/glitch/actions/timelines.js13
1 files changed, 9 insertions, 4 deletions
diff --git a/app/javascript/flavours/glitch/actions/timelines.js b/app/javascript/flavours/glitch/actions/timelines.js
index 9a5b2e6da..3a9d64084 100644
--- a/app/javascript/flavours/glitch/actions/timelines.js
+++ b/app/javascript/flavours/glitch/actions/timelines.js
@@ -19,13 +19,14 @@ export const TIMELINE_DISCONNECT = 'TIMELINE_DISCONNECT';
 
 export const TIMELINE_CONTEXT_UPDATE = 'CONTEXT_UPDATE';
 
-export function refreshTimelineSuccess(timeline, statuses, skipLoading, next) {
+export function refreshTimelineSuccess(timeline, statuses, skipLoading, next, partial) {
   return {
     type: TIMELINE_REFRESH_SUCCESS,
     timeline,
     statuses,
     skipLoading,
     next,
+    partial,
   };
 };
 
@@ -88,7 +89,7 @@ export function refreshTimeline(timelineId, path, params = {}) {
   return function (dispatch, getState) {
     const timeline = getState().getIn(['timelines', timelineId], ImmutableMap());
 
-    if (timeline.get('isLoading') || timeline.get('online')) {
+    if (timeline.get('isLoading') || (timeline.get('online') && !timeline.get('isPartial'))) {
       return;
     }
 
@@ -104,8 +105,12 @@ export function refreshTimeline(timelineId, path, params = {}) {
     dispatch(refreshTimelineRequest(timelineId, skipLoading));
 
     api(getState).get(path, { params }).then(response => {
-      const next = getLinks(response).refs.find(link => link.rel === 'next');
-      dispatch(refreshTimelineSuccess(timelineId, response.data, skipLoading, next ? next.uri : null));
+      if (response.status === 206) {
+        dispatch(refreshTimelineSuccess(timelineId, [], skipLoading, null, true));
+      } else {
+        const next = getLinks(response).refs.find(link => link.rel === 'next');
+        dispatch(refreshTimelineSuccess(timelineId, response.data, skipLoading, next ? next.uri : null, false));
+      }
     }).catch(error => {
       dispatch(refreshTimelineFail(timelineId, error, skipLoading));
     });