diff --git a/src/pages/account-statuses.jsx b/src/pages/account-statuses.jsx index 751931f0..fb4e6783 100644 --- a/src/pages/account-statuses.jsx +++ b/src/pages/account-statuses.jsx @@ -1,3 +1,4 @@ +import { Menu, MenuItem } from '@szhsin/react-menu'; import { useEffect, useMemo, useRef, useState } from 'preact/hooks'; import { useParams, useSearchParams } from 'react-router-dom'; import { useSnapshot } from 'valtio'; @@ -212,6 +213,14 @@ function AccountStatuses() { } }, [featuredTags, tagged, media, excludeReplies, excludeBoosts]); + const accountInstance = useMemo(() => { + if (!account?.url) return null; + const domain = new URL(account.url).hostname; + return domain; + }, [account]); + const sameInstance = instance === accountInstance; + const allowSwitch = !!account && !sameInstance; + return ( + + + } + > + { + (async () => { + try { + const { masto } = api({ + instance: accountInstance, + }); + const acc = await masto.v1.accounts.lookup({ + acct: account.acct, + }); + const { id } = acc; + location.hash = `/${accountInstance}/a/${id}`; + } catch (e) { + console.error(e); + alert('Unable to fetch account info'); + } + })(); + }} + > + {' '} + + Switch to account's instance ({accountInstance}) + + + + } /> ); }