this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Cache search enabled check

+15 -7
+15 -7
src/pages/account-statuses.jsx
··· 10 10 import Menu2 from '../components/menu2'; 11 11 import Timeline from '../components/timeline'; 12 12 import { api } from '../utils/api'; 13 + import pmem from '../utils/pmem'; 13 14 import showToast from '../utils/show-toast'; 14 15 import states from '../utils/states'; 15 16 import { saveStatus } from '../utils/states'; ··· 29 30 } 30 31 })(); 31 32 33 + function _isSearchEnabled(instance) { 34 + const { masto } = api({ instance }); 35 + const results = masto.v2.search.fetch({ 36 + q: 'from:me', 37 + type: 'statuses', 38 + limit: 1, 39 + }); 40 + return !!results?.statuses?.length; 41 + } 42 + const isSearchEnabled = pmem(_isSearchEnabled); 43 + 32 44 function AccountStatuses() { 33 45 const snapStates = useSnapshot(states); 34 46 const { id, ...params } = useParams(); ··· 59 71 if (!sameCurrentInstance) return; 60 72 if (!account?.acct) return; 61 73 (async () => { 62 - const results = await masto.v2.search.fetch({ 63 - q: `from:${account?.acct}`, 64 - type: 'statuses', 65 - limit: 1, 66 - }); 67 - setSearchEnabled(!!results?.statuses?.length); 74 + const enabled = await isSearchEnabled(instance); 75 + setSearchEnabled(enabled); 68 76 })(); 69 - }, [sameCurrentInstance, account?.acct]); 77 + }, [instance, sameCurrentInstance, account?.acct]); 70 78 71 79 async function fetchAccountStatuses(firstLoad) { 72 80 const isValidMonth = /^\d{4}-[01]\d$/.test(month);