[Glitch] Replace recursion in status mapStateToProps
Port dfbadd68374ab5ddcaa75907261bd91da688fc6b to glitch-soc
This commit is contained in:
		
							parent
							
								
									a28f5695f3
								
							
						
					
					
						commit
						837ea32c88
					
				@ -65,31 +65,28 @@ const makeMapStateToProps = () => {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    if (status) {
 | 
					    if (status) {
 | 
				
			||||||
      ancestorsIds = ancestorsIds.withMutations(mutable => {
 | 
					      ancestorsIds = ancestorsIds.withMutations(mutable => {
 | 
				
			||||||
        function addAncestor(id) {
 | 
					        let id = status.get('in_reply_to_id');
 | 
				
			||||||
          if (id) {
 | 
					 | 
				
			||||||
            const inReplyTo = state.getIn(['contexts', 'inReplyTos', id]);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
            mutable.unshift(id);
 | 
					        while (id) {
 | 
				
			||||||
            addAncestor(inReplyTo);
 | 
					          mutable.unshift(id);
 | 
				
			||||||
          }
 | 
					          id = state.getIn(['contexts', 'inReplyTos', id]);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					 | 
				
			||||||
        addAncestor(status.get('in_reply_to_id'));
 | 
					 | 
				
			||||||
      });
 | 
					      });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      descendantsIds = descendantsIds.withMutations(mutable => {
 | 
					      descendantsIds = descendantsIds.withMutations(mutable => {
 | 
				
			||||||
        function addDescendantOf(id) {
 | 
					        const ids = [status.get('id')];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        while (ids.length > 0) {
 | 
				
			||||||
 | 
					          let id        = ids.shift();
 | 
				
			||||||
          const replies = state.getIn(['contexts', 'replies', id]);
 | 
					          const replies = state.getIn(['contexts', 'replies', id]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          if (replies) {
 | 
					          if (replies) {
 | 
				
			||||||
            replies.forEach(reply => {
 | 
					            replies.forEach(reply => {
 | 
				
			||||||
              mutable.push(reply);
 | 
					              mutable.push(reply);
 | 
				
			||||||
              addDescendantOf(reply);
 | 
					              ids.unshift(reply);
 | 
				
			||||||
            });
 | 
					            });
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					 | 
				
			||||||
        addDescendantOf(status.get('id'));
 | 
					 | 
				
			||||||
      });
 | 
					      });
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user