[Glitch] Change detailed status child ordering to sort self-replies on top
Port 6914482d0a6e7e654e17e7f2aa2f6a2acde6c59a to glitch-soc Signed-off-by: Thibaut Girka <thib@sitedethib.com>
This commit is contained in:
		
							parent
							
								
									9044a2b051
								
							
						
					
					
						commit
						759448c24c
					
				@ -82,9 +82,9 @@ const makeMapStateToProps = () => {
 | 
				
			|||||||
  const getDescendantsIds = createSelector([
 | 
					  const getDescendantsIds = createSelector([
 | 
				
			||||||
    (_, { id }) => id,
 | 
					    (_, { id }) => id,
 | 
				
			||||||
    state => state.getIn(['contexts', 'replies']),
 | 
					    state => state.getIn(['contexts', 'replies']),
 | 
				
			||||||
  ], (statusId, contextReplies) => {
 | 
					    state => state.get('statuses'),
 | 
				
			||||||
    let descendantsIds = Immutable.List();
 | 
					  ], (statusId, contextReplies, statuses) => {
 | 
				
			||||||
    descendantsIds = descendantsIds.withMutations(mutable => {
 | 
					    let descendantsIds = [];
 | 
				
			||||||
    const ids = [statusId];
 | 
					    const ids = [statusId];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    while (ids.length > 0) {
 | 
					    while (ids.length > 0) {
 | 
				
			||||||
@ -92,7 +92,7 @@ const makeMapStateToProps = () => {
 | 
				
			|||||||
      const replies = contextReplies.get(id);
 | 
					      const replies = contextReplies.get(id);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      if (statusId !== id) {
 | 
					      if (statusId !== id) {
 | 
				
			||||||
          mutable.push(id);
 | 
					        descendantsIds.push(id);
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      if (replies) {
 | 
					      if (replies) {
 | 
				
			||||||
@ -101,9 +101,19 @@ const makeMapStateToProps = () => {
 | 
				
			|||||||
        });
 | 
					        });
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    });
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return descendantsIds;
 | 
					    let insertAt = descendantsIds.findIndex((id) => statuses.get(id).get('in_reply_to_account_id') !== statuses.get(id).get('account'));
 | 
				
			||||||
 | 
					    if (insertAt !== -1) {
 | 
				
			||||||
 | 
					      descendantsIds.forEach((id, idx) => {
 | 
				
			||||||
 | 
					        if (idx > insertAt && statuses.get(id).get('in_reply_to_account_id') === statuses.get(id).get('account')) {
 | 
				
			||||||
 | 
					          descendantsIds.splice(idx, 1);
 | 
				
			||||||
 | 
					          descendantsIds.splice(insertAt, 0, id);
 | 
				
			||||||
 | 
					          insertAt += 1;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					      });
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return Immutable.List(descendantsIds);
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const mapStateToProps = (state, props) => {
 | 
					  const mapStateToProps = (state, props) => {
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user