feat: implement local caching for vCon data

Persist clients, storage stats, and file lists in local cache to improve initial load performance. Added breadcrumb navigation to the AdminPageHeader.
This commit is contained in:
Team Dark Devil committed 2026-11-16 23:10:44 +06:00
1 parent b42029f67d
commit 1a1c19d7bb
25 files changed
+892 -342

No files matched your search

+4 -4
View File
@@ -8,26 +8,26 @@ import { NewClientModal } from '@/components/sections/NewClientModal';
import { Button } from '@/components/ui/Button';
import { StatStrip } from '@/components/ui/StatStrip';
import { useToast } from '@/components/ui/Toast';
import { getCached, setCached } from '@/lib/vconCache';
import { useCallback, useEffect, useMemo, useState } from 'react';
export default function ClientsPage() {
const { error } = useToast();
const [modalOpen, setModalOpen] = useState(false);
const [clients, setClients] = useState<ClientItem[]>([]);
const [clients, setClients] = useState<ClientItem[]>(() => getCached<ClientItem[]>('vcon:clients', []));
const [search, setSearch] = useState('');
const [statusFilter, setStatusFilter] = useState<ClientStatusFilter>('all');
const [now, setNow] = useState(0);
const [now, setNow] = useState(() => Date.now());
const fetchClients = useCallback(async () => {
const response = await fetch('/api/clients');
if (!response.ok) throw new Error('Unable to load clients');
const data = await response.json();
setClients(data.clients || []);
setClients(setCached('vcon:clients', data.clients || []));
}, []);
useEffect(() => {
fetchClients().catch(() => {
setClients([]);
error('Unable to load clients', 'Could not fetch registered clients.');
});
}, [error, fetchClients]);