Fix wrong account rendered on Account page

This commit is contained in:
Lim Chee Aun 2025-02-01 09:57:39 +08:00
parent 8ba431b001
commit 2f39e8ff27
2 changed files with 28 additions and 25 deletions

40
src/locales/en.po generated
View file

@ -100,7 +100,7 @@ msgstr "Following"
#: src/components/account-info.jsx:423
#: src/components/account-info.jsx:780
#: src/pages/account-statuses.jsx:483
#: src/pages/account-statuses.jsx:479
#: src/pages/search.jsx:328
#: src/pages/search.jsx:475
msgid "Posts"
@ -116,7 +116,7 @@ msgstr ""
#: src/components/status.jsx:1875
#: src/components/status.jsx:2479
#: src/components/status.jsx:2482
#: src/pages/account-statuses.jsx:527
#: src/pages/account-statuses.jsx:523
#: src/pages/accounts.jsx:110
#: src/pages/hashtag.jsx:200
#: src/pages/list.jsx:158
@ -980,7 +980,7 @@ msgid "Poll"
msgstr ""
#: src/components/drafts.jsx:250
#: src/pages/account-statuses.jsx:364
#: src/pages/account-statuses.jsx:360
msgid "Media"
msgstr ""
@ -1377,7 +1377,7 @@ msgid "Followed Hashtags"
msgstr ""
#: src/components/nav-menu.jsx:262
#: src/pages/account-statuses.jsx:330
#: src/pages/account-statuses.jsx:326
#: src/pages/filters.jsx:54
#: src/pages/filters.jsx:93
#: src/pages/hashtag.jsx:340
@ -2525,69 +2525,69 @@ msgstr ""
msgid "{accountDisplay} ({monthYear})"
msgstr ""
#: src/pages/account-statuses.jsx:320
#: src/pages/account-statuses.jsx:316
msgid "Clear filters"
msgstr ""
#: src/pages/account-statuses.jsx:323
#: src/pages/account-statuses.jsx:319
msgid "Clear"
msgstr ""
#: src/pages/account-statuses.jsx:337
#: src/pages/account-statuses.jsx:333
msgid "Showing post with replies"
msgstr ""
#: src/pages/account-statuses.jsx:342
#: src/pages/account-statuses.jsx:338
msgid "+ Replies"
msgstr ""
#: src/pages/account-statuses.jsx:348
#: src/pages/account-statuses.jsx:344
msgid "Showing posts without boosts"
msgstr ""
#: src/pages/account-statuses.jsx:353
#: src/pages/account-statuses.jsx:349
msgid "- Boosts"
msgstr ""
#: src/pages/account-statuses.jsx:359
#: src/pages/account-statuses.jsx:355
msgid "Showing posts with media"
msgstr ""
#. placeholder {0}: tag.name
#: src/pages/account-statuses.jsx:376
#: src/pages/account-statuses.jsx:372
msgid "Showing posts tagged with #{0}"
msgstr ""
#. placeholder {1}: date.toLocaleString(i18n.locale, { month: 'long', year: 'numeric', })
#: src/pages/account-statuses.jsx:415
#: src/pages/account-statuses.jsx:411
msgid "Showing posts in {1}"
msgstr "Showing posts in {1}"
#: src/pages/account-statuses.jsx:504
#: src/pages/account-statuses.jsx:500
msgid "Nothing to see here yet."
msgstr ""
#: src/pages/account-statuses.jsx:505
#: src/pages/account-statuses.jsx:501
#: src/pages/public.jsx:98
#: src/pages/trending.jsx:450
msgid "Unable to load posts"
msgstr ""
#: src/pages/account-statuses.jsx:546
#: src/pages/account-statuses.jsx:576
#: src/pages/account-statuses.jsx:542
#: src/pages/account-statuses.jsx:572
msgid "Unable to fetch account info"
msgstr ""
#. placeholder {0}: accountInstance ? ( <> {' '} (<b>{punycode.toUnicode(accountInstance)}</b>) </> ) : null
#: src/pages/account-statuses.jsx:553
#: src/pages/account-statuses.jsx:549
msgid "Switch to account's instance {0}"
msgstr ""
#: src/pages/account-statuses.jsx:583
#: src/pages/account-statuses.jsx:579
msgid "Switch to my instance (<0>{currentInstance}</0>)"
msgstr ""
#: src/pages/account-statuses.jsx:645
#: src/pages/account-statuses.jsx:641
msgid "Month"
msgstr ""

View file

@ -255,12 +255,8 @@ function AccountStatuses() {
}
useTitle(title, '/:instance?/a/:id');
const fetchAccountPromiseRef = useRef();
const fetchAccount = useCallback(() => {
const fetchPromise =
fetchAccountPromiseRef.current || masto.v1.accounts.$select(id).fetch();
fetchAccountPromiseRef.current = fetchPromise;
return fetchPromise;
return memFetchAccount(id, masto);
}, [id, masto]);
useEffect(() => {
@ -691,4 +687,11 @@ function MonthPicker(props) {
);
}
function fetchAccount(id, masto) {
return masto.v1.accounts.$select(id).fetch();
}
const memFetchAccount = pmem(fetchAccount, {
maxAge: 30 * 60 * 1000, // 30 minutes
});
export default AccountStatuses;