Add loading skeleton to NostrSettings page

This commit is contained in:
Alex Gleason committed 2025-09-19 12:22:10 -05:00
1 parent 6f399af544
commit 1cccd8c254
4 files changed
+37 -9

No files matched your search

+4 -2
View File
@@ -33,7 +33,8 @@ describe('AccountSwitcher', () => {
},
otherUsers: [],
setLogin: vi.fn(),
removeLogin: vi.fn()
removeLogin: vi.fn(),
isLoading: false
});
render(<AccountSwitcher onAddAccountClick={vi.fn()} />);
@@ -53,7 +54,8 @@ describe('AccountSwitcher', () => {
currentUser: undefined,
otherUsers: [],
setLogin: vi.fn(),
removeLogin: vi.fn()
removeLogin: vi.fn(),
isLoading: false
});
const { container } = render(<AccountSwitcher onAddAccountClick={vi.fn()} />);
+8 -4
View File
@@ -62,7 +62,8 @@ describe('LoginArea', () => {
},
otherUsers: [],
setLogin: vi.fn(),
removeLogin: vi.fn()
removeLogin: vi.fn(),
isLoading: false
});
render(<LoginArea />);
@@ -76,7 +77,8 @@ describe('LoginArea', () => {
currentUser: undefined,
otherUsers: [],
setLogin: vi.fn(),
removeLogin: vi.fn()
removeLogin: vi.fn(),
isLoading: false
});
render(<LoginArea />);
@@ -97,7 +99,8 @@ describe('LoginArea', () => {
currentUser: undefined,
otherUsers: [],
setLogin: vi.fn(),
removeLogin: vi.fn()
removeLogin: vi.fn(),
isLoading: false
});
const { rerender } = render(<LoginArea />);
@@ -119,7 +122,8 @@ describe('LoginArea', () => {
},
otherUsers: [],
setLogin: vi.fn(),
removeLogin: vi.fn()
removeLogin: vi.fn(),
isLoading: false
});
rerender(<LoginArea />);
+2 -1
View File
@@ -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,
};
}
+23 -2
View File
@@ -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() {
</CardTitle>
</CardHeader>
<CardContent className="space-y-4">
{authors.length === 0 ? (
{isLoading ? (
<div className="border rounded-lg overflow-hidden">
{/* Loading skeleton for accounts */}
{[...Array(2)].map((_, i) => (
<div key={i} className="flex items-center gap-3 p-3 border-b last:border-b-0">
<Skeleton className="h-10 w-10 rounded-full" />
<div className="flex-1 space-y-1">
<Skeleton className="h-4 w-32" />
</div>
<Skeleton className="h-8 w-8 rounded" />
</div>
))}
{/* Add account button skeleton */}
<div className="flex items-center gap-3 p-3">
<Skeleton className="h-10 w-10 rounded-full" />
<div className="flex-1 space-y-1">
<Skeleton className="h-4 w-24" />
</div>
</div>
</div>
) : authors.length === 0 ? (
<div className="text-center py-8">
<User className="h-12 w-12 mx-auto text-muted-foreground mb-4" />
<p className="text-muted-foreground mb-4">