mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-02-25 01:08:50 +01: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 { useHotkeys } from 'react-hotkeys-hook';
|
||||||
|
|
||||||
import { api } from '../utils/api';
|
import { api } from '../utils/api';
|
||||||
|
import states from '../utils/states';
|
||||||
|
|
||||||
import AccountInfo from './account-info';
|
import AccountInfo from './account-info';
|
||||||
|
|
||||||
|
@ -10,6 +12,12 @@ function AccountSheet({ account, instance: propInstance, onClose }) {
|
||||||
|
|
||||||
const escRef = useHotkeys('esc', onClose, [onClose]);
|
const escRef = useHotkeys('esc', onClose, [onClose]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!isString) {
|
||||||
|
states.accounts[`${account.id}@${instance}`] = account;
|
||||||
|
}
|
||||||
|
}, [account]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
ref={escRef}
|
ref={escRef}
|
||||||
|
|
|
@ -74,18 +74,18 @@ function AccountStatuses() {
|
||||||
|
|
||||||
const { displayName, acct, emojis } = account || {};
|
const { displayName, acct, emojis } = account || {};
|
||||||
|
|
||||||
const TimelineStart = useMemo(
|
const TimelineStart = useMemo(() => {
|
||||||
() => (
|
const cachedAccount = snapStates.accounts[`${id}@${instance}`];
|
||||||
|
return (
|
||||||
<AccountInfo
|
<AccountInfo
|
||||||
instance={instance}
|
instance={instance}
|
||||||
account={id}
|
account={cachedAccount || id}
|
||||||
fetchAccount={() => masto.v1.accounts.fetch(id)}
|
fetchAccount={() => masto.v1.accounts.fetch(id)}
|
||||||
authenticated={authenticated}
|
authenticated={authenticated}
|
||||||
standalone
|
standalone
|
||||||
/>
|
/>
|
||||||
),
|
|
||||||
[id, instance, authenticated],
|
|
||||||
);
|
);
|
||||||
|
}, [id, instance, authenticated]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Timeline
|
<Timeline
|
||||||
|
|
|
@ -27,6 +27,7 @@ const states = proxy({
|
||||||
spoilers: {},
|
spoilers: {},
|
||||||
scrollPositions: {},
|
scrollPositions: {},
|
||||||
unfurledLinks: {},
|
unfurledLinks: {},
|
||||||
|
accounts: {},
|
||||||
// Modals
|
// Modals
|
||||||
showCompose: false,
|
showCompose: false,
|
||||||
showSettings: false,
|
showSettings: false,
|
||||||
|
|
Loading…
Reference in a new issue