TootList: mentions in toot links to profile page
All checks were successful
/ depoly (push) Successful in 1m17s
All checks were successful
/ depoly (push) Successful in 1m17s
- bug: main toot in TootBottomSheet does not link profile
This commit is contained in:
parent
92cc451811
commit
31b27237cd
5 changed files with 165 additions and 91 deletions
|
@ -17,22 +17,15 @@ type Timeline<T extends mastodon.DefaultPaginationParams> = {
|
|||
|
||||
type TimelineParamsOf<T> = T extends Timeline<infer P> ? P : never;
|
||||
|
||||
export function createTimelineSnapshot<
|
||||
T extends Timeline<mastodon.DefaultPaginationParams>,
|
||||
>(timeline: Accessor<T>, limit: Accessor<number>) {
|
||||
export function createTimelineControlsForArray(
|
||||
status: () => mastodon.v1.Status[] | undefined,
|
||||
) {
|
||||
const lookup = new ReactiveMap<string, TreeNode<mastodon.v1.Status>>();
|
||||
const [shot, { refetch }] = createResource(
|
||||
() => [timeline(), limit()] as const,
|
||||
async ([tl, limit]) => {
|
||||
const ls = await tl.list({ limit }).next();
|
||||
return ls.value;
|
||||
},
|
||||
);
|
||||
|
||||
const [threads, setThreads] = createStore([] as mastodon.v1.Status["id"][]);
|
||||
|
||||
createEffect(() => {
|
||||
const nls = catchError(shot, (e) => console.error(e));
|
||||
const nls = status();
|
||||
if (!nls) return;
|
||||
|
||||
setThreads([]);
|
||||
|
@ -70,24 +63,40 @@ export function createTimelineSnapshot<
|
|||
setThreads(newThreads);
|
||||
});
|
||||
|
||||
return [
|
||||
{
|
||||
list: threads,
|
||||
get(id: string) {
|
||||
return lookup.get(id);
|
||||
},
|
||||
getPath(id: string) {
|
||||
const node = lookup.get(id);
|
||||
if (!node) return;
|
||||
return collectPath(node);
|
||||
},
|
||||
set(id: string, value: mastodon.v1.Status) {
|
||||
const node = untrack(() => lookup.get(id));
|
||||
if (!node) return;
|
||||
node.value = value;
|
||||
lookup.set(id, node);
|
||||
},
|
||||
return {
|
||||
list: threads,
|
||||
get(id: string) {
|
||||
return lookup.get(id);
|
||||
},
|
||||
getPath(id: string) {
|
||||
const node = lookup.get(id);
|
||||
if (!node) return;
|
||||
return collectPath(node);
|
||||
},
|
||||
set(id: string, value: mastodon.v1.Status) {
|
||||
const node = untrack(() => lookup.get(id));
|
||||
if (!node) return;
|
||||
node.value = value;
|
||||
lookup.set(id, node);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export function createTimelineSnapshot<
|
||||
T extends Timeline<mastodon.DefaultPaginationParams>,
|
||||
>(timeline: Accessor<T>, limit: Accessor<number>) {
|
||||
const [shot, { refetch }] = createResource(
|
||||
() => [timeline(), limit()] as const,
|
||||
async ([tl, limit]) => {
|
||||
const ls = await tl.list({ limit }).next();
|
||||
return ls.value;
|
||||
},
|
||||
);
|
||||
|
||||
const controls = createTimelineControlsForArray(shot);
|
||||
|
||||
return [
|
||||
controls,
|
||||
shot,
|
||||
{
|
||||
refetch,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue