New shared primitives: - Toaster + toast-store, ConfirmSheet, Modal, focusTrap action, pullToRefresh action, avatarPalette + initials helper, Skeleton, HeartBurst, haptics, export-status store with onClearAuth hook Critical UX/a11y: - Replaced window.confirm with branded ConfirmSheet - Focus management + Escape on every modal (PIN, Lightbox, Onboarding, ContextSheet, data-mode sheet, leave-confirm, HTML guide, host/admin ban + PIN-display modals) - Sheet backdrops are real buttons with aria-label - Silent ApiError catches now surface via global Toaster Major polish: - Dark-mode parity on HashtagChips + avatars (shared palette) - Conditional Export tab in BottomNav (badge dot when ZIP ready) - Back chevrons on /recover (history-aware) and /export - Upload composer discard confirmation when content is staged - Camera segmented Photo/Video shutter - PIN auto-submit on 4th digit, paste-flash-free (controlled input) - Welcome-back toast on /feed after PIN recovery Minor: - Skeleton states on feed; pull-to-refresh with live drag indicator - Haptics on like / capture / submit / PIN-copy / onboarding complete - Comment 500-char counter; quota "Fast voll" / "Limit erreicht" labels - Onboarding pip ≥24px tap targets; long-press hint step - overscroll-behavior lock on <html> while feed mounted - teardownExportStatus wired via onClearAuth (covers 401 + explicit logout) - ConfirmSheet per-instance titleId; Modal requires titleId or ariaLabel Tests (7 new Playwright specs): - 01-auth/pin-auto-submit, 01-auth/back-chevron - 03-feed/confirm-sheet-delete, 03-feed/toast-on-failure - 09-mobile/focus-trap, 09-mobile/sheet-escape, 09-mobile/upload-cancel-confirm FOLLOWUPS.md captures the deferred AT inert containment work with acceptance criteria + implementation sketches. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
63 lines
2.2 KiB
TypeScript
63 lines
2.2 KiB
TypeScript
// Single source of truth for "is export released and is the ZIP ready?". Used
|
|
// by the BottomNav to surface the Export tab on demand, and by the export
|
|
// page to render status. Hydrates lazily on first subscribe; reacts to the
|
|
// `export-progress` / `export-available` SSE events so the nav updates live.
|
|
|
|
import { writable } from 'svelte/store';
|
|
import { api } from './api';
|
|
import { onSseEvent } from './sse';
|
|
import { getToken, onClearAuth } from './auth';
|
|
|
|
export interface ExportJob {
|
|
status: 'locked' | 'pending' | 'running' | 'done' | 'failed';
|
|
progress_pct: number;
|
|
}
|
|
|
|
export interface ExportStatusSnapshot {
|
|
released: boolean;
|
|
zip: ExportJob | null;
|
|
html: ExportJob | null;
|
|
}
|
|
|
|
const empty: ExportStatusSnapshot = { released: false, zip: null, html: null };
|
|
|
|
export const exportStatus = writable<ExportStatusSnapshot>(empty);
|
|
|
|
let hydrated = false;
|
|
let sseUnsubs: Array<() => void> = [];
|
|
|
|
export async function refreshExportStatus(): Promise<void> {
|
|
if (!getToken()) return;
|
|
try {
|
|
const data = await api.get<ExportStatusSnapshot>('/export/status');
|
|
exportStatus.set(data);
|
|
} catch {
|
|
// /export/status can 403 for guests on locked events; that's expected.
|
|
exportStatus.set(empty);
|
|
}
|
|
}
|
|
|
|
export function initExportStatus(): void {
|
|
if (hydrated) return;
|
|
hydrated = true;
|
|
void refreshExportStatus();
|
|
sseUnsubs.push(onSseEvent('export-progress', () => { void refreshExportStatus(); }));
|
|
sseUnsubs.push(onSseEvent('export-available', () => { void refreshExportStatus(); }));
|
|
}
|
|
|
|
export function teardownExportStatus(): void {
|
|
for (const u of sseUnsubs) u();
|
|
sseUnsubs = [];
|
|
hydrated = false;
|
|
exportStatus.set(empty);
|
|
}
|
|
|
|
// Auto-reset on every clearAuth path (explicit logout + api.ts 401 auto-clear).
|
|
// Imported for side-effect by anyone who pulls in this module — the BottomNav
|
|
// does that statically, and BottomNav itself is statically imported by
|
|
// +layout.svelte, so this side-effect runs at app boot, well before any API
|
|
// call can 401. If a future refactor lazy-loads the BottomNav (dynamic import,
|
|
// route-level code-split), move the side-effect to +layout.svelte's onMount
|
|
// so the hook isn't gated on a conditional component.
|
|
onClearAuth(teardownExportStatus);
|