From e2b6f2df6a758a28d677958f9332b51fff4cddfc Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Wed, 11 Jan 2023 17:45:37 +0800 Subject: [PATCH] Auto-threadify when open a status page with context --- src/pages/status.jsx | 7 ++++++- src/utils/states.js | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/pages/status.jsx b/src/pages/status.jsx index f251d819..599d64a7 100644 --- a/src/pages/status.jsx +++ b/src/pages/status.jsx @@ -14,7 +14,7 @@ import RelativeTime from '../components/relative-time'; import Status from '../components/status'; import htmlContentLength from '../utils/html-content-length'; import shortenNumber from '../utils/shorten-number'; -import states, { saveStatus } from '../utils/states'; +import states, { saveStatus, threadifyStatus } from '../utils/states'; import store from '../utils/store'; import { getCurrentAccount } from '../utils/store-utils'; import useDebouncedCallback from '../utils/useDebouncedCallback'; @@ -160,6 +160,11 @@ function StatusPage({ id }) { console.log({ allStatuses }); setStatuses(allStatuses); cachedStatusesMap.current[id] = allStatuses; + + // Let's threadify this one + // Note that all non-hero statuses will trigger saveStatus which will threadify them too + // By right, at this point, all descendant statuses should be cached + threadifyStatus(heroStatus); } catch (e) { console.error(e); setUIState('error'); diff --git a/src/utils/states.js b/src/utils/states.js index f180f3ac..acad28bd 100644 --- a/src/utils/states.js +++ b/src/utils/states.js @@ -45,7 +45,7 @@ export function saveStatus(status, opts) { } } -function threadifyStatus(status) { +export function threadifyStatus(status) { // Return all statuses in the thread, via inReplyToId, if inReplyToAccountId === account.id let fetchIndex = 0; async function traverse(status, index = 0) {