managarten/memoro/apps/mobile/features/storage/hooks/useUnuploadedCount.ts
Till-JS e7f5f942f3 chore: initial commit - consolidate 4 projects into monorepo
Projects included:
- maerchenzauber (NestJS backend + Expo mobile + SvelteKit web + Astro landing)
- manacore (Expo mobile + SvelteKit web + Astro landing)
- manadeck (NestJS backend + Expo mobile + SvelteKit web)
- memoro (Expo mobile + SvelteKit web + Astro landing)

This commit preserves the current state before monorepo restructuring.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-22 23:38:24 +01:00

36 lines
1.2 KiB
TypeScript

/**
* Hook to track the count of unuploaded audio files
*
* This hook subscribes to the upload status store and returns the count
* of audio files that have NOT_UPLOADED or FAILED status.
* These are recordings that need user attention to upload/retry.
*/
import { useEffect, useState } from 'react';
import { useUploadStatusStore } from '../store/uploadStatusStore';
import { UploadStatus } from '../uploadStatus.types';
export function useUnuploadedCount() {
const [count, setCount] = useState(0);
const statusMap = useUploadStatusStore((state) => state.statusMap);
const isInitialized = useUploadStatusStore((state) => state.isInitialized);
useEffect(() => {
if (!isInitialized) {
return;
}
// Count records with NOT_UPLOADED or FAILED status
// Both represent recordings that need user action to upload
const pendingCount = Array.from(statusMap.values()).filter(
(record) =>
record.status === UploadStatus.NOT_UPLOADED ||
record.status === UploadStatus.FAILED
).length;
console.debug(`[useUnuploadedCount] Pending uploads: ${pendingCount}`);
setCount(pendingCount);
}, [statusMap, isInitialized]);
return count;
}