Skip to content

Voice-to-text dictation app with local (Nvidia Parakeet/Whisper) and cloud models (BYOK). Privacy-first and available cross-platform.

1.7 KB
Raw Blame
import { useEffect } from 'react';
import { startMeetingRecoveryOnce } from '@/lib/meetingRecovery';
import { useDictionaryStore } from '@/store/useDictionaryStore';
import { useSnippetsStore } from '@/store/useSnippetsStore';
import { useNotesStore } from '@/store/useNotesStore';
import { useConfigStore } from '@/store/useConfigStore';
import { useTranscriptStore } from '@/store/useTranscriptStore';

export function useAppInit() {
  const loadDictionary = useDictionaryStore((state) => state.load);
  const isDictionaryLoaded = useDictionaryStore((state) => state.isLoaded);
  const loadSnippets = useSnippetsStore((state) => state.load);
  const isSnippetsLoaded = useSnippetsStore((state) => state.isLoaded);
  const initNotes = useNotesStore((state) => state.initialize);
  const isNotesInitialized = useNotesStore((state) => state.isInitialized);
  const loadConfig = useConfigStore((state) => state.loadConfig);
  const loadTranscripts = useTranscriptStore((state) => state.loadTranscripts);

  useEffect(() => {
    if (!isDictionaryLoaded) loadDictionary();
    // Hydrate snippets at startup so expansion + hints work for keyboard dictation
    // even when the Dictionary screen was never opened.
    if (!isSnippetsLoaded) loadSnippets();
    if (!isNotesInitialized) initNotes();
    loadConfig();
    loadTranscripts();
  }, [
    loadDictionary,
    isDictionaryLoaded,
    loadSnippets,
    isSnippetsLoaded,
    initNotes,
    isNotesInitialized,
    loadConfig,
    loadTranscripts,
  ]);

  // After notes load and before any meeting can start: recover meeting notes whose
  // process died mid-recording or mid-pipeline.
  useEffect(() => {
    if (isNotesInitialized) startMeetingRecoveryOnce();
  }, [isNotesInitialized]);
}