Skip to content

Commit

Permalink
Fix refreshing featured toots when the new collection is empty (masto…
Browse files Browse the repository at this point in the history
  • Loading branch information
ClearlyClaire authored and hiyuki2578 committed Oct 2, 2019
1 parent 524f80d commit f7a8501
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions app/javascript/mastodon/reducers/timelines.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit f7a8501

Please sign in to comment.