diff --git a/src/pages/account-statuses.jsx b/src/pages/account-statuses.jsx index 61de5c09..f7c61465 100644 --- a/src/pages/account-statuses.jsx +++ b/src/pages/account-statuses.jsx @@ -57,6 +57,7 @@ function AccountStatuses() { const tagged = searchParams.get('tagged'); const media = !!searchParams.get('media'); const { masto, instance, authenticated } = api({ instance: params.instance }); + const { masto: currentMasto, instance: currentInstance } = api(); const accountStatusesIterator = useRef(); const allSearchParams = [month, excludeReplies, excludeBoosts, tagged, media]; @@ -67,8 +68,8 @@ function AccountStatuses() { }, allSearchParams); const sameCurrentInstance = useMemo( - () => instance === api().instance, - [instance], + () => instance === currentInstance, + [instance, currentInstance], ); const [searchEnabled, setSearchEnabled] = useState(false); useEffect(() => { @@ -516,6 +517,29 @@ function AccountStatuses() { Switch to account's instance ({accountInstance}) + {!sameCurrentInstance && ( + { + (async () => { + try { + const acc = await currentMasto.v1.accounts.lookup({ + acct: account.acct + '@' + instance, + }); + const { id } = acc; + location.hash = `/${currentInstance}/a/${id}`; + } catch (e) { + console.error(e); + alert('Unable to fetch account info'); + } + })(); + }} + > + {' '} + + Switch to my instance ({currentInstance}) + + + )} } /> diff --git a/src/pages/hashtag.jsx b/src/pages/hashtag.jsx index 552c93b3..4f5bfbdc 100644 --- a/src/pages/hashtag.jsx +++ b/src/pages/hashtag.jsx @@ -42,7 +42,11 @@ function Hashtags({ media: mediaView, columnMode, ...props }) { const { masto, instance, authenticated } = api({ instance: props?.instance || params.instance, }); - const { authenticated: currentAuthenticated } = api(); + const { + masto: currentMasto, + instance: currentInstance, + authenticated: currentAuthenticated, + } = api(); const hashtagTitle = hashtags.map((t) => `#${t}`).join(' '); const hashtagPostTitle = media ? ` (Media only)` : ''; const title = instance @@ -376,6 +380,20 @@ function Hashtags({ media: mediaView, columnMode, ...props }) { > Go to another instance… + {currentInstance !== instance && ( + { + location.hash = `/${currentInstance}/t/${hashtags.join( + '+', + )}${linkParams}`; + }} + > + {' '} + + Go to my instance ({currentInstance}) + + + )} } /> diff --git a/src/pages/public.jsx b/src/pages/public.jsx index 52437f38..089d084a 100644 --- a/src/pages/public.jsx +++ b/src/pages/public.jsx @@ -21,6 +21,7 @@ function Public({ local, columnMode, ...props }) { const { masto, instance } = api({ instance: props?.instance || params.instance, }); + const { masto: currentMasto, instance: currentInstance } = api(); const title = `${isLocal ? 'Local' : 'Federated'} timeline (${instance})`; useTitle(title, isLocal ? `/:instance?/p/l` : `/:instance?/p`); // const navigate = useNavigate(); @@ -138,6 +139,20 @@ function Public({ local, columnMode, ...props }) { > Go to another instance… + {currentInstance !== instance && ( + { + location.hash = isLocal + ? `/${currentInstance}/p/l` + : `/${currentInstance}/p`; + }} + > + {' '} + + Go to my instance ({currentInstance}) + + + )} } /> diff --git a/src/pages/trending.jsx b/src/pages/trending.jsx index 97a9c3e4..c1126aa1 100644 --- a/src/pages/trending.jsx +++ b/src/pages/trending.jsx @@ -38,6 +38,7 @@ function Trending({ columnMode, ...props }) { const { masto, instance } = api({ instance: props?.instance || params.instance, }); + const { masto: currentMasto, instance: currentInstance } = api(); const title = `Trending (${instance})`; useTitle(title, `/:instance?/trending`); // const navigate = useNavigate(); @@ -291,6 +292,18 @@ function Trending({ columnMode, ...props }) { > Go to another instance… + {currentInstance !== instance && ( + { + location.hash = `/${currentInstance}/trending`; + }} + > + {' '} + + Go to my instance ({currentInstance}) + + + )} } />