mirror of
https://github.com/fromchat-messenger/web.git
synced 2026-09-22 19:15:08 +03:00
Stop typing on message sent
This commit is contained in:
@@ -203,6 +203,22 @@ export class TypingManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Immediately stop typing for public chat (called when message is sent)
|
||||||
|
*/
|
||||||
|
async stopTypingOnMessage(): Promise<void> {
|
||||||
|
this.clearStopTypingTimeout("public");
|
||||||
|
await this.sendStopTyping();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Immediately stop DM typing (called when message is sent)
|
||||||
|
*/
|
||||||
|
async stopDmTypingOnMessage(recipientId: number): Promise<void> {
|
||||||
|
this.clearStopTypingTimeout(`dm_${recipientId}`);
|
||||||
|
await this.sendStopDmTyping(recipientId);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cleanup all timeouts
|
* Cleanup all timeouts
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ interface ChatInputWrapperProps {
|
|||||||
onProvideFileAdder?: (adder: (files: File[]) => void) => void;
|
onProvideFileAdder?: (adder: (files: File[]) => void) => void;
|
||||||
messagePanelRef?: React.RefObject<HTMLDivElement | null>;
|
messagePanelRef?: React.RefObject<HTMLDivElement | null>;
|
||||||
onTyping?: () => void;
|
onTyping?: () => void;
|
||||||
|
onStopTyping?: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function ChatInputWrapper(
|
export function ChatInputWrapper(
|
||||||
@@ -37,7 +38,8 @@ export function ChatInputWrapper(
|
|||||||
onCloseEdit,
|
onCloseEdit,
|
||||||
onProvideFileAdder,
|
onProvideFileAdder,
|
||||||
messagePanelRef,
|
messagePanelRef,
|
||||||
onTyping
|
onTyping,
|
||||||
|
onStopTyping
|
||||||
}: ChatInputWrapperProps
|
}: ChatInputWrapperProps
|
||||||
) {
|
) {
|
||||||
const [message, setMessage] = useState("");
|
const [message, setMessage] = useState("");
|
||||||
@@ -124,6 +126,8 @@ export function ChatInputWrapper(
|
|||||||
setMessage("");
|
setMessage("");
|
||||||
setAttachmentsVisible(false);
|
setAttachmentsVisible(false);
|
||||||
if (onClearReply) onClearReply();
|
if (onClearReply) onClearReply();
|
||||||
|
// Stop typing indicator when message is sent
|
||||||
|
if (onStopTyping) onStopTyping();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -385,6 +385,14 @@ export function MessagePanelRenderer({ panel }: MessagePanelRendererProps) {
|
|||||||
typingManager.sendTyping();
|
typingManager.sendTyping();
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
|
onStopTyping={() => {
|
||||||
|
if (panel.isDm()) {
|
||||||
|
const dmPanel = panel as DMPanel;
|
||||||
|
typingManager.stopDmTypingOnMessage(dmPanel.getRecipientId()!);
|
||||||
|
} else {
|
||||||
|
typingManager.stopTypingOnMessage();
|
||||||
|
}
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|||||||
Reference in New Issue
Block a user