From e0e1196c9eeb8902637b673d3d4388f084db375a Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Sat, 11 Mar 2023 21:33:55 +0800 Subject: [PATCH] Make account info load wayyyy faster on Profile page --- src/components/account-sheet.jsx | 8 ++++++++ src/pages/account-statuses.jsx | 12 ++++++------ src/utils/states.js | 1 + 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/components/account-sheet.jsx b/src/components/account-sheet.jsx index 78b89aba..e615b23d 100644 --- a/src/components/account-sheet.jsx +++ b/src/components/account-sheet.jsx @@ -1,6 +1,8 @@ +import { useEffect } from 'preact/hooks'; import { useHotkeys } from 'react-hotkeys-hook'; import { api } from '../utils/api'; +import states from '../utils/states'; import AccountInfo from './account-info'; @@ -10,6 +12,12 @@ function AccountSheet({ account, instance: propInstance, onClose }) { const escRef = useHotkeys('esc', onClose, [onClose]); + useEffect(() => { + if (!isString) { + states.accounts[`${account.id}@${instance}`] = account; + } + }, [account]); + return (
( + const TimelineStart = useMemo(() => { + const cachedAccount = snapStates.accounts[`${id}@${instance}`]; + return ( masto.v1.accounts.fetch(id)} authenticated={authenticated} standalone /> - ), - [id, instance, authenticated], - ); + ); + }, [id, instance, authenticated]); return (