Fix flash of un-nested comments
This commit is contained in:
parent
96a38e5df1
commit
f110ac6812
1 changed files with 21 additions and 4 deletions
|
@ -21,8 +21,20 @@ function StatusPage({ id }) {
|
||||||
const heroStatusRef = useRef();
|
const heroStatusRef = useRef();
|
||||||
|
|
||||||
useEffect(async () => {
|
useEffect(async () => {
|
||||||
// If id is completely new, reset the whole list
|
const containsStatus = statuses.find((s) => s.id === id);
|
||||||
if (!statuses.find((s) => s.id === id)) {
|
const statusesWithSameAccountID = statuses.filter(
|
||||||
|
(s) => s.accountID === containsStatus?.accountID,
|
||||||
|
);
|
||||||
|
if (statusesWithSameAccountID.length > 1) {
|
||||||
|
setStatuses(
|
||||||
|
statusesWithSameAccountID.map((s) => ({
|
||||||
|
...s,
|
||||||
|
thread: true,
|
||||||
|
descendant: undefined,
|
||||||
|
ancestor: undefined,
|
||||||
|
})),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
setStatuses([{ id }]);
|
setStatuses([{ id }]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,10 +88,15 @@ function StatusPage({ id }) {
|
||||||
console.log({ ancestors, descendants, nestedDescendants });
|
console.log({ ancestors, descendants, nestedDescendants });
|
||||||
|
|
||||||
const allStatuses = [
|
const allStatuses = [
|
||||||
...ancestors.map((s) => ({ id: s.id, ancestor: true })),
|
...ancestors.map((s) => ({
|
||||||
{ id },
|
id: s.id,
|
||||||
|
ancestor: true,
|
||||||
|
accountID: s.account.id,
|
||||||
|
})),
|
||||||
|
{ id, accountID: heroStatus.account.id },
|
||||||
...nestedDescendants.map((s) => ({
|
...nestedDescendants.map((s) => ({
|
||||||
id: s.id,
|
id: s.id,
|
||||||
|
accountID: s.account.id,
|
||||||
descendant: true,
|
descendant: true,
|
||||||
thread: s.account.id === heroStatus.account.id,
|
thread: s.account.id === heroStatus.account.id,
|
||||||
replies: s.__replies?.map((r) => r.id),
|
replies: s.__replies?.map((r) => r.id),
|
||||||
|
|
Loading…
Add table
Reference in a new issue