feat(web): service-worker notifications and composer/scroll UX fixes
Some checks failed
CI / test (push) Failing after 21s
Some checks failed
CI / test (push) Failing after 21s
- register notifications service worker and handle click-to-open chat/message - route realtime notifications through service worker with fallback - support ?chat=&message= deep-link navigation in chats page - enforce 1s minimum voice message length - lift scroll-to-bottom button to avoid overlap with composer action
This commit is contained in:
@@ -280,15 +280,21 @@ export function MessageComposer() {
|
||||
recorder.ondataavailable = (event) => chunksRef.current.push(event.data);
|
||||
recorder.onstop = async () => {
|
||||
const shouldSend = sendVoiceOnStopRef.current;
|
||||
const durationMs = recordingStartedAtRef.current ? Date.now() - recordingStartedAtRef.current : 0;
|
||||
const data = [...chunksRef.current];
|
||||
chunksRef.current = [];
|
||||
if (recordingStreamRef.current) {
|
||||
recordingStreamRef.current.getTracks().forEach((track) => track.stop());
|
||||
recordingStreamRef.current = null;
|
||||
}
|
||||
recordingStartedAtRef.current = null;
|
||||
if (!shouldSend || data.length === 0) {
|
||||
return;
|
||||
}
|
||||
if (durationMs < 1000) {
|
||||
setUploadError("Voice message is too short. Minimum length is 1 second.");
|
||||
return;
|
||||
}
|
||||
const blob = new Blob(data, { type: "audio/webm" });
|
||||
const file = new File([blob], `voice-${Date.now()}.webm`, { type: "audio/webm" });
|
||||
await handleUpload(file, "voice");
|
||||
@@ -313,7 +319,6 @@ export function MessageComposer() {
|
||||
recorderRef.current.stop();
|
||||
}
|
||||
recorderRef.current = null;
|
||||
recordingStartedAtRef.current = null;
|
||||
setRecordingState("idle");
|
||||
setRecordSeconds(0);
|
||||
}
|
||||
@@ -567,8 +572,9 @@ export function MessageComposer() {
|
||||
disabled={recordingState !== "idle" || !activeChatId}
|
||||
onClick={handleSend}
|
||||
type="button"
|
||||
title="Send message"
|
||||
>
|
||||
➤
|
||||
↑
|
||||
</button>
|
||||
) : (
|
||||
<button
|
||||
@@ -578,6 +584,7 @@ export function MessageComposer() {
|
||||
disabled={isUploading || !activeChatId}
|
||||
onPointerDown={onMicPointerDown}
|
||||
type="button"
|
||||
title="Hold to record voice"
|
||||
>
|
||||
🎤
|
||||
</button>
|
||||
|
||||
Reference in New Issue
Block a user