From: ThibG Date: Wed, 5 Jun 2019 11:39:59 +0000 (+0200) Subject: Fix refreshing featured toots when the new collection is empty (#10971) X-Git-Url: https://git.xn--scling-oua.cat.family/?a=commitdiff_plain;h=d34a3a2cc72c12ae5119150a8ac18dd8fb7a4e6b;p=mastodon.git Fix refreshing featured toots when the new collection is empty (#10971) Fixes #10945 --- diff --git a/app/javascript/mastodon/reducers/timelines.js b/app/javascript/mastodon/reducers/timelines.js index 6a972f967..309a95a19 100644 --- a/app/javascript/mastodon/reducers/timelines.js +++ b/app/javascript/mastodon/reducers/timelines.js @@ -35,14 +35,12 @@ const expandNormalizedTimeline = (state, timeline, statuses, next, isPartial, is if (!next && !isLoadingRecent) mMap.set('hasMore', false); - if (!statuses.isEmpty()) { + if (timeline.endsWith(':pinned')) { + mMap.set('items', statuses.map(status => status.get('id'))); + } else if (!statuses.isEmpty()) { mMap.update('items', ImmutableList(), oldIds => { const newIds = statuses.map(status => status.get('id')); - if (timeline.indexOf(':pinned') !== -1) { - return newIds; - } - const lastIndex = oldIds.findLastIndex(id => id !== null && compareId(id, newIds.last()) >= 0) + 1; const firstIndex = oldIds.take(lastIndex).findLastIndex(id => id !== null && compareId(id, newIds.first()) > 0);