mirror of
https://github.com/shuaiplus/nodewarden.git
synced 2026-06-20 21:00:41 +00:00
b990f17a3e
- Introduced `shell.css` for the main application layout, including styles for the app shell, top bar, and user interactions. - Created `tokens.css` to define CSS variables for theming, including colors, shadows, and transition durations for light and dark modes. - Developed `vault.css` for the vault component, implementing grid layouts, sidebar styles, search inputs, and list item designs.
38 lines
1.0 KiB
TypeScript
38 lines
1.0 KiB
TypeScript
import type { Cipher, Folder, Send } from '../types';
|
|
import { parseJson, type AuthedFetch } from './shared';
|
|
|
|
interface VaultSyncResponse {
|
|
ciphers?: Cipher[];
|
|
folders?: Folder[];
|
|
sends?: Send[];
|
|
}
|
|
|
|
const pendingSyncRequests = new WeakMap<AuthedFetch, Promise<VaultSyncResponse>>();
|
|
|
|
export async function loadVaultSyncSnapshot(authedFetch: AuthedFetch): Promise<VaultSyncResponse> {
|
|
const existing = pendingSyncRequests.get(authedFetch);
|
|
if (existing) return existing;
|
|
|
|
const request = (async () => {
|
|
const resp = await authedFetch('/api/sync', {
|
|
cache: 'no-store',
|
|
headers: {
|
|
'Cache-Control': 'no-cache',
|
|
Pragma: 'no-cache',
|
|
},
|
|
});
|
|
if (!resp.ok) throw new Error('Failed to load vault');
|
|
const body = await parseJson<VaultSyncResponse>(resp);
|
|
return body || {};
|
|
})();
|
|
|
|
pendingSyncRequests.set(authedFetch, request);
|
|
try {
|
|
return await request;
|
|
} finally {
|
|
if (pendingSyncRequests.get(authedFetch) === request) {
|
|
pendingSyncRequests.delete(authedFetch);
|
|
}
|
|
}
|
|
}
|