From 5c9ba9177a87d007135b63f79ded4329c49083e2 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Mon, 23 Sep 2019 00:48:31 +0200 Subject: [PATCH] [Glitch] Revert "Change timelines to add new items to pending items when scrolled down #11867" Port 8c4b5f7cef60700af7ae64c7b524d899a1d033c5 to glitch-soc Signed-off-by: Thibaut Girka --- app/javascript/flavours/glitch/reducers/notifications.js | 4 ++-- app/javascript/flavours/glitch/reducers/timelines.js | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/javascript/flavours/glitch/reducers/notifications.js b/app/javascript/flavours/glitch/reducers/notifications.js index 8dc7a4aba3..8d5c6785c5 100644 --- a/app/javascript/flavours/glitch/reducers/notifications.js +++ b/app/javascript/flavours/glitch/reducers/notifications.js @@ -52,7 +52,7 @@ const notificationToMap = (state, notification) => ImmutableMap({ const normalizeNotification = (state, notification, usePendingItems) => { const top = !shouldCountUnreadNotifications(state); - if (usePendingItems || !top || !state.get('pendingItems').isEmpty()) { + if (usePendingItems || !state.get('pendingItems').isEmpty()) { return state.update('pendingItems', list => list.unshift(notificationToMap(state, notification))).update('unread', unread => unread + 1); } @@ -82,7 +82,7 @@ const expandNormalizedNotifications = (state, notifications, next, isLoadingRece return state.withMutations(mutable => { if (!items.isEmpty()) { - usePendingItems = isLoadingRecent && (usePendingItems || !mutable.get('top') || !mutable.get('pendingItems').isEmpty()); + usePendingItems = isLoadingRecent && (usePendingItems || !mutable.get('pendingItems').isEmpty()); mutable.update(usePendingItems ? 'pendingItems' : 'items', list => { const lastIndex = 1 + list.findLastIndex( diff --git a/app/javascript/flavours/glitch/reducers/timelines.js b/app/javascript/flavours/glitch/reducers/timelines.js index e6bef18e99..df88a6c23e 100644 --- a/app/javascript/flavours/glitch/reducers/timelines.js +++ b/app/javascript/flavours/glitch/reducers/timelines.js @@ -40,7 +40,8 @@ const expandNormalizedTimeline = (state, timeline, statuses, next, isPartial, is if (timeline.endsWith(':pinned')) { mMap.set('items', statuses.map(status => status.get('id'))); } else if (!statuses.isEmpty()) { - usePendingItems = isLoadingRecent && (usePendingItems || !mMap.get('top') || !mMap.get('pendingItems').isEmpty()); + usePendingItems = isLoadingRecent && (usePendingItems || !mMap.get('pendingItems').isEmpty()); + mMap.update(usePendingItems ? 'pendingItems' : 'items', ImmutableList(), oldIds => { const newIds = statuses.map(status => status.get('id')); const lastIndex = oldIds.findLastIndex(id => id !== null && compareId(id, newIds.last()) >= 0) + 1; @@ -62,7 +63,7 @@ const expandNormalizedTimeline = (state, timeline, statuses, next, isPartial, is const updateTimeline = (state, timeline, status, usePendingItems) => { const top = state.getIn([timeline, 'top']); - if (usePendingItems || !top || !state.getIn([timeline, 'pendingItems']).isEmpty()) { + if (usePendingItems || !state.getIn([timeline, 'pendingItems']).isEmpty()) { if (state.getIn([timeline, 'pendingItems'], ImmutableList()).includes(status.get('id')) || state.getIn([timeline, 'items'], ImmutableList()).includes(status.get('id'))) { return state; }