Fix “load more” adding older toots/notifications to pending items (#11883)
This commit is contained in:
		
							parent
							
								
									0e6390753d
								
							
						
					
					
						commit
						577706987d
					
				
					 3 changed files with 7 additions and 6 deletions
				
			
		|  | @ -54,7 +54,7 @@ const normalizeNotification = (state, notification, usePendingItems) => { | |||
|   }); | ||||
| }; | ||||
| 
 | ||||
| const expandNormalizedNotifications = (state, notifications, next, usePendingItems) => { | ||||
| const expandNormalizedNotifications = (state, notifications, next, isLoadingRecent, usePendingItems) => { | ||||
|   let items = ImmutableList(); | ||||
| 
 | ||||
|   notifications.forEach((n, i) => { | ||||
|  | @ -63,7 +63,7 @@ const expandNormalizedNotifications = (state, notifications, next, usePendingIte | |||
| 
 | ||||
|   return state.withMutations(mutable => { | ||||
|     if (!items.isEmpty()) { | ||||
|       usePendingItems = usePendingItems || !mutable.get('top') || !mutable.get('pendingItems').isEmpty(); | ||||
|       usePendingItems = isLoadingRecent && (usePendingItems || !mutable.get('top') || !mutable.get('pendingItems').isEmpty()); | ||||
| 
 | ||||
|       mutable.update(usePendingItems ? 'pendingItems' : 'items', list => { | ||||
|         const lastIndex = 1 + list.findLastIndex( | ||||
|  | @ -119,7 +119,7 @@ export default function notifications(state = initialState, action) { | |||
|   case NOTIFICATIONS_UPDATE: | ||||
|     return normalizeNotification(state, action.notification, action.usePendingItems); | ||||
|   case NOTIFICATIONS_EXPAND_SUCCESS: | ||||
|     return expandNormalizedNotifications(state, action.notifications, action.next, action.usePendingItems); | ||||
|     return expandNormalizedNotifications(state, action.notifications, action.next, action.isLoadingRecent, action.usePendingItems); | ||||
|   case ACCOUNT_BLOCK_SUCCESS: | ||||
|     return filterNotifications(state, [action.relationship.id]); | ||||
|   case ACCOUNT_MUTE_SUCCESS: | ||||
|  |  | |||
|  | @ -40,7 +40,7 @@ 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 = usePendingItems || !mMap.get('top') || !mMap.get('pendingItems').isEmpty(); | ||||
|       usePendingItems = isLoadingRecent && (usePendingItems || !mMap.get('top') || !mMap.get('pendingItems').isEmpty()); | ||||
|       mMap.update(usePendingItems ? 'pendingItems' : 'items', ImmutableList(), oldIds => { | ||||
|         const newIds = statuses.map(status => status.get('id')); | ||||
| 
 | ||||
|  |  | |||
		Reference in a new issue