mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-16 17:39:40 +02:00
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>
36 lines
1.2 KiB
TypeScript
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;
|
|
}
|