From f45acd3518d9ca09bc71c17532604a21b1c5e1d6 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 5 Jan 2026 16:21:05 +0000 Subject: [PATCH] chore: remove unused LoginHandler and LogoutHandler components --- src/components/LoginHandler.tsx | 95 -------------------------------- src/components/LogoutHandler.tsx | 95 -------------------------------- 2 files changed, 190 deletions(-) delete mode 100644 src/components/LoginHandler.tsx delete mode 100644 src/components/LogoutHandler.tsx diff --git a/src/components/LoginHandler.tsx b/src/components/LoginHandler.tsx deleted file mode 100644 index cfe8501..0000000 --- a/src/components/LoginHandler.tsx +++ /dev/null @@ -1,95 +0,0 @@ -import { useEffect } from "react"; -import { toast } from "sonner"; -import { Check, X, Info } from "lucide-react"; -import type { ReadOnlyAccount } from "@/lib/account-types"; -import accountManager from "@/services/accounts"; - -interface LoginHandlerProps { - action: "add-account" | "error" | "open-dialog"; - account?: ReadOnlyAccount; - message?: string; -} - -/** - * LoginHandler - Executes login command actions - * - * This component handles the result of the /login command: - * - add-account: Adds account to AccountManager and sets as active - * - error: Shows error toast - * - open-dialog: Shows info about opening login dialog (UI coming soon) - */ -export default function LoginHandler({ - action, - account, - message, -}: LoginHandlerProps) { - useEffect(() => { - const handleAction = async () => { - switch (action) { - case "add-account": - if (!account) { - toast.error("Failed to add account", { - description: "No account provided", - icon: , - }); - return; - } - - try { - // Add account to manager - accountManager.addAccount(account); - - // Set as active account - accountManager.setActive(account.id); - - // Show success toast - toast.success("Account added successfully", { - description: `Logged in as ${account.pubkey.slice(0, 8)}...${account.pubkey.slice(-8)}`, - icon: , - }); - } catch (error) { - toast.error("Failed to add account", { - description: - error instanceof Error ? error.message : "Unknown error", - icon: , - }); - } - break; - - case "error": - toast.error("Login failed", { - description: message || "Unknown error occurred", - icon: , - }); - break; - - case "open-dialog": - toast.info("Login dialog", { - description: - "Login dialog UI coming soon. For now, use: login ", - icon: , - duration: 5000, - }); - break; - - default: - toast.error("Unknown action", { - description: `Unhandled action: ${action}`, - icon: , - }); - } - }; - - handleAction(); - }, [action, account, message]); - - // This component doesn't render anything visible - it just executes the action - return ( -
-
-

Processing login...

-

This window can be closed.

-
-
- ); -} diff --git a/src/components/LogoutHandler.tsx b/src/components/LogoutHandler.tsx deleted file mode 100644 index f8ed76e..0000000 --- a/src/components/LogoutHandler.tsx +++ /dev/null @@ -1,95 +0,0 @@ -import { useEffect } from "react"; -import { toast } from "sonner"; -import { LogOut } from "lucide-react"; -import accountManager from "@/services/accounts"; -import { useObservableMemo } from "applesauce-react/hooks"; - -interface LogoutHandlerProps { - action: "logout" | "logout-all"; - all: boolean; -} - -/** - * LogoutHandler - Executes logout command actions - * - * This component handles the result of the /logout command: - * - logout: Removes the active account - * - logout-all: Removes all accounts - */ -export default function LogoutHandler({ action, all }: LogoutHandlerProps) { - const activeAccount = useObservableMemo(() => accountManager.active$, []); - const allAccounts = useObservableMemo(() => accountManager.accounts$, []); - - useEffect(() => { - const handleLogout = () => { - if (action === "logout-all" || all) { - // Remove all accounts - if (allAccounts.length === 0) { - toast.info("No accounts to remove", { - icon: , - }); - return; - } - - const confirmLogoutAll = window.confirm( - `Remove all ${allAccounts.length} account(s)? This cannot be undone.`, - ); - - if (!confirmLogoutAll) { - toast.info("Logout cancelled", { - icon: , - }); - return; - } - - // Remove all accounts - allAccounts.forEach((account) => { - accountManager.removeAccount(account); - }); - - toast.success("All accounts removed", { - description: `Removed ${allAccounts.length} account(s)`, - icon: , - }); - } else { - // Remove only active account - if (!activeAccount) { - toast.info("No active account to remove", { - description: "You are not logged in", - icon: , - }); - return; - } - - // If there are other accounts, switch to the first one before removing current - const otherAccounts = allAccounts.filter( - (acc) => acc.id !== activeAccount.id, - ); - if (otherAccounts.length > 0) { - accountManager.setActive(otherAccounts[0].id); - } - - // Remove the account - accountManager.removeAccount(activeAccount); - - toast.success("Logged out", { - description: `Removed ${activeAccount.pubkey.slice(0, 8)}...${activeAccount.pubkey.slice(-8)}`, - icon: , - }); - } - }; - - handleLogout(); - }, [action, all, activeAccount, allAccounts]); - - // This component doesn't render anything visible - it just executes the action - return ( -
-
- -

Processing logout...

-

This window can be closed.

-
-
- ); -}