mirror of
https://github.com/cheeaun/phanpy.git
synced 2024-11-22 17:25:40 +03:00
Make account info load wayyyy faster on Profile page
This commit is contained in:
parent
4ddd1d3219
commit
e0e1196c9e
3 changed files with 15 additions and 6 deletions
|
@ -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 (
|
||||
<div
|
||||
ref={escRef}
|
||||
|
|
|
@ -74,18 +74,18 @@ function AccountStatuses() {
|
|||
|
||||
const { displayName, acct, emojis } = account || {};
|
||||
|
||||
const TimelineStart = useMemo(
|
||||
() => (
|
||||
const TimelineStart = useMemo(() => {
|
||||
const cachedAccount = snapStates.accounts[`${id}@${instance}`];
|
||||
return (
|
||||
<AccountInfo
|
||||
instance={instance}
|
||||
account={id}
|
||||
account={cachedAccount || id}
|
||||
fetchAccount={() => masto.v1.accounts.fetch(id)}
|
||||
authenticated={authenticated}
|
||||
standalone
|
||||
/>
|
||||
),
|
||||
[id, instance, authenticated],
|
||||
);
|
||||
);
|
||||
}, [id, instance, authenticated]);
|
||||
|
||||
return (
|
||||
<Timeline
|
||||
|
|
|
@ -27,6 +27,7 @@ const states = proxy({
|
|||
spoilers: {},
|
||||
scrollPositions: {},
|
||||
unfurledLinks: {},
|
||||
accounts: {},
|
||||
// Modals
|
||||
showCompose: false,
|
||||
showSettings: false,
|
||||
|
|
Loading…
Reference in a new issue