createTimeline: fix the mutate won't work
This commit is contained in:
		
							parent
							
								
									44c9e55928
								
							
						
					
					
						commit
						23dc34dbbf
					
				
					 1 changed files with 20 additions and 15 deletions
				
			
		| 
						 | 
					@ -288,20 +288,23 @@ export function createTimeline<
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    for (const status of chk.chunk) {
 | 
					    untrack(() => {
 | 
				
			||||||
      const node = untrack(() => lookup.get(status.id))!;
 | 
					      for (const status of chk.chunk) {
 | 
				
			||||||
      const parent = untrack(() =>
 | 
					        const node = lookup.get(status.id)!;
 | 
				
			||||||
        status.inReplyToId ? lookup.get(status.inReplyToId) : undefined,
 | 
					        const parent = status.inReplyToId
 | 
				
			||||||
      );
 | 
					          ? lookup.get(status.inReplyToId)
 | 
				
			||||||
      if (parent) {
 | 
					          : undefined;
 | 
				
			||||||
        const children = parent.children ?? [];
 | 
					
 | 
				
			||||||
        if (!children.find((x) => x.value.id == status.id)) {
 | 
					        if (parent) {
 | 
				
			||||||
          children.push(node);
 | 
					          const children = parent.children ?? [];
 | 
				
			||||||
 | 
					          if (!children.find((x) => x.value.id == status.id)) {
 | 
				
			||||||
 | 
					            children.push(node);
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					          parent.children = children;
 | 
				
			||||||
 | 
					          node.parent = parent;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        parent.children = children;
 | 
					 | 
				
			||||||
        node.parent = parent;
 | 
					 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    }
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const nThreadIds = chk.chunk
 | 
					    const nThreadIds = chk.chunk
 | 
				
			||||||
      .filter((x, i) => !existence[i])
 | 
					      .filter((x, i) => !existence[i])
 | 
				
			||||||
| 
						 | 
					@ -314,9 +317,11 @@ export function createTimeline<
 | 
				
			||||||
        setThreads((threads) => [...nThreadIds, ...threads]);
 | 
					        setThreads((threads) => [...nThreadIds, ...threads]);
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      setThreads((threads) =>
 | 
					      untrack(() => {
 | 
				
			||||||
        threads.filter((id) => (lookup.get(id)!.children?.length ?? 0) === 0),
 | 
					        setThreads((threads) =>
 | 
				
			||||||
      );
 | 
					          threads.filter((id) => (lookup.get(id)!.children?.length ?? 0) === 0),
 | 
				
			||||||
 | 
					        );
 | 
				
			||||||
 | 
					      });
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue