From 6ff3cd1fd311011868c8d7fb7f90b818ae7f9349 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?nicole=20miko=C5=82ajczyk?= Date: Fri, 16 Jan 2026 00:54:09 +0100 Subject: [PATCH] pl-fe: maybe fix useAcct MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: nicole mikołajczyk --- packages/pl-fe/src/hooks/use-acct.ts | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/packages/pl-fe/src/hooks/use-acct.ts b/packages/pl-fe/src/hooks/use-acct.ts index ce3b112ea..7f05392df 100644 --- a/packages/pl-fe/src/hooks/use-acct.ts +++ b/packages/pl-fe/src/hooks/use-acct.ts @@ -1,18 +1,27 @@ +import { useMemo } from 'react'; + import { displayFqn } from 'pl-fe/utils/state'; import { useAppSelector } from './use-app-selector'; import { useInstance } from './use-instance'; +import { useOwnAccount } from './use-own-account'; import type { Account } from 'pl-api'; -const useAcct = (account?: Pick): string | undefined => { +const useAcct = (account?: Pick): string | undefined => { const fqn = useAppSelector((state) => displayFqn(state)); const instance = useInstance(); - if (!account) return; - if (!fqn) return account.acct; - if (account.local === false) return account.fqn; - return `${account.acct}@${instance.domain}`; + const localUrl = useOwnAccount().account?.url; + + return useMemo(() => { + if (!account) return; + if (!fqn) return account.acct; + const localHost = localUrl ? new URL(localUrl).host : null; + const otherHost = new URL(account.url).host; + if (account.local === false || (localHost && localHost !== otherHost)) return account.fqn; + return `${account.acct}@${instance.domain}`; + }, [account?.acct, fqn, instance.domain, localUrl]); }; export {