From 75910abd8f9b40a08e8b4a79979b99ec841c6cd9 Mon Sep 17 00:00:00 2001
From: geta6 <getakura@gmail.com>
Date: Tue, 18 Apr 2017 20:10:49 +0900
Subject: Add hasMore field to account timeline (#2066)

---
 app/assets/javascripts/components/reducers/timelines.jsx | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

(limited to 'app/assets/javascripts/components/reducers/timelines.jsx')

diff --git a/app/assets/javascripts/components/reducers/timelines.jsx b/app/assets/javascripts/components/reducers/timelines.jsx
index 675a52759..fa9863250 100644
--- a/app/assets/javascripts/components/reducers/timelines.jsx
+++ b/app/assets/javascripts/components/reducers/timelines.jsx
@@ -144,10 +144,11 @@ const normalizeAccountTimeline = (state, accountId, statuses, replace = false) =
   return state.updateIn(['accounts_timelines', accountId], Immutable.Map(), map => map
     .set('isLoading', false)
     .set('loaded', true)
+    .set('next', true)
     .update('items', Immutable.List(), list => (replace ? ids : list.unshift(...ids))));
 };
 
-const appendNormalizedAccountTimeline = (state, accountId, statuses) => {
+const appendNormalizedAccountTimeline = (state, accountId, statuses, next) => {
   let moreIds = Immutable.List([]);
 
   statuses.forEach((status, i) => {
@@ -157,6 +158,7 @@ const appendNormalizedAccountTimeline = (state, accountId, statuses) => {
 
   return state.updateIn(['accounts_timelines', accountId], Immutable.Map(), map => map
     .set('isLoading', false)
+    .set('next', next)
     .update('items', list => list.push(...moreIds)));
 };
 
@@ -299,7 +301,7 @@ export default function timelines(state = initialState, action) {
   case ACCOUNT_TIMELINE_FETCH_SUCCESS:
     return normalizeAccountTimeline(state, action.id, Immutable.fromJS(action.statuses), action.replace);
   case ACCOUNT_TIMELINE_EXPAND_SUCCESS:
-    return appendNormalizedAccountTimeline(state, action.id, Immutable.fromJS(action.statuses));
+    return appendNormalizedAccountTimeline(state, action.id, Immutable.fromJS(action.statuses), action.next);
   case ACCOUNT_BLOCK_SUCCESS:
   case ACCOUNT_MUTE_SUCCESS:
     return filterTimelines(state, action.relationship, action.statuses);
-- 
cgit 

