diff --git a/src/components/Layout.tsx b/src/components/Layout.tsx index ac78241..8dd0c64 100644 --- a/src/components/Layout.tsx +++ b/src/components/Layout.tsx @@ -16,6 +16,7 @@ import { import { LoginArea } from '@/components/auth/LoginArea'; import { useSasquatchGuide } from '@/hooks/useSasquatchGuide'; import { LanguageToggle } from '@/components/LanguageToggle'; +import { clearTranslationMemory } from '@/lib/translation'; import { useCurrentUser } from '@/hooks/useCurrentUser'; import { useTranslation } from '@/contexts/language'; import { useLoggedInAccounts } from '@/hooks/useLoggedInAccounts'; @@ -812,7 +813,7 @@ export function Layout({ children, noPadding }: LayoutProps) { {user && ( removeLogin(currentAccount?.id || '')} + onLogout={() => { clearTranslationMemory(); removeLogin(currentAccount?.id || ''); }} onSetStatus={() => setShowStatusDialog(true)} onAddAccount={() => setShowAddAccount(true)} /> @@ -1038,6 +1039,7 @@ export function Layout({ children, noPadding }: LayoutProps) { size="lg" className="w-full justify-center gap-3 text-red-400 border-red-500/50 hover:bg-red-500/20 hover:text-red-300 hover:border-red-500 h-12 text-base font-bold" onClick={() => { + clearTranslationMemory(); removeLogin(currentAccount?.id || ''); setMobileMenuOpen(false); }} diff --git a/src/components/auth/AccountSwitcher.tsx b/src/components/auth/AccountSwitcher.tsx index 956ccb6..298f134 100644 --- a/src/components/auth/AccountSwitcher.tsx +++ b/src/components/auth/AccountSwitcher.tsx @@ -12,6 +12,7 @@ import { import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar.tsx'; import { WalletModal } from '@/components/WalletModal'; import { clearDmDecryptCache } from '@/lib/dmDecryptCache'; +import { clearTranslationMemory } from '@/lib/translation'; import { useLoggedInAccounts, type Account } from '@/hooks/useLoggedInAccounts'; import { genUserName } from '@/lib/genUserName'; import { useTranslation } from '@/contexts/language'; @@ -102,6 +103,7 @@ export function AccountSwitcher({ onAddAccountClick }: AccountSwitcherProps) { // Drop this account's plaintext DM cache (device-local) on logout so // another account on the same device can't read it from IndexedDB. void clearDmDecryptCache(currentUser.id).catch(() => {}); + clearTranslationMemory(); removeLogin(currentUser.id); }} className='flex items-center gap-2 cursor-pointer p-2 rounded-md text-red-500' diff --git a/src/lib/translation.ts b/src/lib/translation.ts index 1e477c1..85cf5df 100644 --- a/src/lib/translation.ts +++ b/src/lib/translation.ts @@ -145,4 +145,9 @@ export async function translateText(params: TranslateParams): Promise { /** Clear the in-memory translation cache (e.g. on logout). */ export function clearTranslationMemory(): void { memoryCache.clear(); + rejectAll(new Error('CLEARED')); + if (worker) { + worker.terminate(); + worker = null; + } }