Compare commits

...

2 commits

Author SHA1 Message Date
thislight
2836e857ad
TootComposer: minor cleanup
All checks were successful
/ depoly (push) Successful in 1m14s
2024-11-10 16:51:36 +08:00
thislight
23dc34dbbf
createTimeline: fix the mutate won't work 2024-11-10 16:42:37 +08:00
2 changed files with 20 additions and 19 deletions

View file

@ -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),
);
});
}); });
}); });

View file

@ -3,8 +3,6 @@ import {
createMemo, createMemo,
createRenderEffect, createRenderEffect,
createSignal, createSignal,
createUniqueId,
onMount,
Show, Show,
type Accessor, type Accessor,
type Component, type Component,
@ -43,14 +41,12 @@ import {
} from "@suid/icons-material"; } from "@suid/icons-material";
import type { Account } from "../accounts/stores"; import type { Account } from "../accounts/stores";
import "./TootComposer.css"; import "./TootComposer.css";
import { makeEventListener } from "@solid-primitives/event-listener";
import BottomSheet from "../material/BottomSheet"; import BottomSheet from "../material/BottomSheet";
import { useLanguage } from "../platform/i18n"; import { useLanguage } from "../platform/i18n";
import iso639_1 from "iso-639-1"; import iso639_1 from "iso-639-1";
import ChooseTootLang from "./ChooseTootLang"; import ChooseTootLang from "./ChooseTootLang";
import type { mastodon } from "masto"; import type { mastodon } from "masto";
import cardStyles from "../material/cards.module.css"; import cardStyles from "../material/cards.module.css";
import { Title } from "../material/typography";
import Menu, { createManagedMenuState } from "../material/Menu"; import Menu, { createManagedMenuState } from "../material/Menu";
import { useDefaultSession } from "../masto/clients"; import { useDefaultSession } from "../masto/clients";
import { resolveCustomEmoji } from "../masto/toot"; import { resolveCustomEmoji } from "../masto/toot";