fix(typing): stop indicator on blur and chat switch
Some checks are pending
CI / test (push) Has started running
Some checks are pending
CI / test (push) Has started running
This commit is contained in:
@@ -108,6 +108,7 @@ export function MessageComposer() {
|
|||||||
const pointerUpHandlerRef = useRef<((event: globalThis.PointerEvent) => void) | null>(null);
|
const pointerUpHandlerRef = useRef<((event: globalThis.PointerEvent) => void) | null>(null);
|
||||||
const recordingStateRef = useRef<RecordingState>("idle");
|
const recordingStateRef = useRef<RecordingState>("idle");
|
||||||
const lastEditingMessageIdRef = useRef<number | null>(null);
|
const lastEditingMessageIdRef = useRef<number | null>(null);
|
||||||
|
const prevActiveChatIdRef = useRef<number | null>(null);
|
||||||
|
|
||||||
const [isUploading, setIsUploading] = useState(false);
|
const [isUploading, setIsUploading] = useState(false);
|
||||||
const [uploadProgress, setUploadProgress] = useState(0);
|
const [uploadProgress, setUploadProgress] = useState(0);
|
||||||
@@ -255,6 +256,15 @@ export function MessageComposer() {
|
|||||||
}
|
}
|
||||||
}, [activeChatId]);
|
}, [activeChatId]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const prev = prevActiveChatIdRef.current;
|
||||||
|
if (prev && prev !== activeChatId) {
|
||||||
|
const ws = getWs();
|
||||||
|
ws?.send(JSON.stringify({ event: "typing_stop", payload: { chat_id: prev } }));
|
||||||
|
}
|
||||||
|
prevActiveChatIdRef.current = activeChatId;
|
||||||
|
}, [activeChatId]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const onVisibility = () => {
|
const onVisibility = () => {
|
||||||
if (document.visibilityState === "hidden" && recordingStateRef.current === "recording") {
|
if (document.visibilityState === "hidden" && recordingStateRef.current === "recording") {
|
||||||
@@ -1297,6 +1307,11 @@ export function MessageComposer() {
|
|||||||
sendRealtimeChatEvent(next.trim().length > 0 ? "typing_start" : "typing_stop");
|
sendRealtimeChatEvent(next.trim().length > 0 ? "typing_start" : "typing_stop");
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
|
onBlur={() => {
|
||||||
|
if (activeChatId) {
|
||||||
|
sendRealtimeChatEvent("typing_stop");
|
||||||
|
}
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{hasTextToSend ? (
|
{hasTextToSend ? (
|
||||||
|
|||||||
Reference in New Issue
Block a user