diff --git a/src/components/auth/AccountSwitcher.test.tsx b/src/components/auth/AccountSwitcher.test.tsx index e503b526..5899e82b 100644 --- a/src/components/auth/AccountSwitcher.test.tsx +++ b/src/components/auth/AccountSwitcher.test.tsx @@ -33,7 +33,8 @@ describe('AccountSwitcher', () => { }, otherUsers: [], setLogin: vi.fn(), - removeLogin: vi.fn() + removeLogin: vi.fn(), + isLoading: false }); render(); @@ -53,7 +54,8 @@ describe('AccountSwitcher', () => { currentUser: undefined, otherUsers: [], setLogin: vi.fn(), - removeLogin: vi.fn() + removeLogin: vi.fn(), + isLoading: false }); const { container } = render(); diff --git a/src/components/auth/LoginArea.test.tsx b/src/components/auth/LoginArea.test.tsx index a17600b8..492995b1 100644 --- a/src/components/auth/LoginArea.test.tsx +++ b/src/components/auth/LoginArea.test.tsx @@ -62,7 +62,8 @@ describe('LoginArea', () => { }, otherUsers: [], setLogin: vi.fn(), - removeLogin: vi.fn() + removeLogin: vi.fn(), + isLoading: false }); render(); @@ -76,7 +77,8 @@ describe('LoginArea', () => { currentUser: undefined, otherUsers: [], setLogin: vi.fn(), - removeLogin: vi.fn() + removeLogin: vi.fn(), + isLoading: false }); render(); @@ -97,7 +99,8 @@ describe('LoginArea', () => { currentUser: undefined, otherUsers: [], setLogin: vi.fn(), - removeLogin: vi.fn() + removeLogin: vi.fn(), + isLoading: false }); const { rerender } = render(); @@ -119,7 +122,8 @@ describe('LoginArea', () => { }, otherUsers: [], setLogin: vi.fn(), - removeLogin: vi.fn() + removeLogin: vi.fn(), + isLoading: false }); rerender(); diff --git a/src/hooks/useLoggedInAccounts.ts b/src/hooks/useLoggedInAccounts.ts index bffdbab2..22f79db4 100644 --- a/src/hooks/useLoggedInAccounts.ts +++ b/src/hooks/useLoggedInAccounts.ts @@ -14,7 +14,7 @@ export function useLoggedInAccounts() { const { nostr } = useNostr(); const { logins, setLogin, removeLogin } = useNostrLogin(); - const { data: authors = [] } = useQuery({ + const { data: authors = [], isLoading } = useQuery({ queryKey: ['logins', logins.map((l) => l.id).join(';')], queryFn: async ({ signal }) => { const events = await nostr.query( @@ -52,5 +52,6 @@ export function useLoggedInAccounts() { otherUsers, setLogin, removeLogin, + isLoading, }; } \ No newline at end of file diff --git a/src/pages/NostrSettings.tsx b/src/pages/NostrSettings.tsx index 59c495c1..5587769a 100644 --- a/src/pages/NostrSettings.tsx +++ b/src/pages/NostrSettings.tsx @@ -3,6 +3,7 @@ import { Button } from '@/components/ui/button'; import { Label } from '@/components/ui/label'; import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'; import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'; +import { Skeleton } from '@/components/ui/skeleton'; import { RelaySelector } from '@/components/RelaySelector'; import LoginDialog from '@/components/auth/LoginDialog'; import SignupDialog from '@/components/auth/SignupDialog'; @@ -15,7 +16,7 @@ import { useState } from 'react'; export function NostrSettings() { const isMobile = useIsMobile(); const navigate = useNavigate(); - const { authors, currentUser, setLogin, removeLogin } = useLoggedInAccounts(); + const { authors, currentUser, setLogin, removeLogin, isLoading } = useLoggedInAccounts(); const [showLoginDialog, setShowLoginDialog] = useState(false); const [showSignupDialog, setShowSignupDialog] = useState(false); @@ -86,7 +87,27 @@ export function NostrSettings() { - {authors.length === 0 ? ( + {isLoading ? ( + + {/* Loading skeleton for accounts */} + {[...Array(2)].map((_, i) => ( + + + + + + + + ))} + {/* Add account button skeleton */} + + + + + + + + ) : authors.length === 0 ? (