Matthias Nott
2026-03-07 0e888d62af1434fef231e11a5c307a5b48a8deb1
components/chat/VoiceButton.tsx
....@@ -10,7 +10,7 @@
1010 import { stopPlayback } from "../../services/audio";
1111
1212 interface VoiceButtonProps {
13
- onVoiceRecorded: (uri: string) => void;
13
+ onVoiceRecorded: (uri: string, durationMs?: number) => void;
1414 }
1515
1616 const VOICE_BUTTON_SIZE = 72;
....@@ -98,7 +98,11 @@
9898 });
9999 const uri = recorder.uri;
100100 if (uri) {
101
- onVoiceRecorded(uri);
101
+ // currentTime is in seconds after stop
102
+ const durationMs = recorder.currentTime > 0
103
+ ? Math.round(recorder.currentTime * 1000)
104
+ : undefined;
105
+ onVoiceRecorded(uri, durationMs);
102106 }
103107 } catch (err) {
104108 console.error("Failed to stop recording:", err);