this repo has no description
0
fork

Configure Feed

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

Auto-update self account info

And fix isSelf not working in some cases

+31 -5
+31 -5
src/components/account-info.jsx
··· 131 131 const isString = typeof account === 'string'; 132 132 const [info, setInfo] = useState(isString ? null : account); 133 133 134 - const isSelf = useMemo( 135 - () => account.id === store.session.get('currentAccount'), 136 - [account?.id], 137 - ); 138 - 139 134 const sameCurrentInstance = useMemo( 140 135 () => instance === currentInstance, 141 136 [instance, currentInstance], ··· 197 192 } 198 193 } 199 194 } 195 + 196 + const isSelf = useMemo( 197 + () => id === store.session.get('currentAccount'), 198 + [id], 199 + ); 200 + 201 + useEffect(() => { 202 + const infoHasEssentials = !!( 203 + info?.id && 204 + info?.username && 205 + info?.acct && 206 + info?.avatar && 207 + info?.avatarStatic && 208 + info?.displayName && 209 + info?.url 210 + ); 211 + if (isSelf && instance && infoHasEssentials) { 212 + const accounts = store.local.getJSON('accounts'); 213 + let updated = false; 214 + accounts.forEach((account) => { 215 + if (account.info.id === info.id && account.instanceURL === instance) { 216 + account.info = info; 217 + updated = true; 218 + } 219 + }); 220 + if (updated) { 221 + console.log('Updated account info', info); 222 + store.local.setJSON('accounts', accounts); 223 + } 224 + } 225 + }, [isSelf, info, instance]); 200 226 201 227 const accountInstance = useMemo(() => { 202 228 if (!url) return null;