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
|
||||
*/
|
||||
|
||||
@@ -21,6 +21,7 @@ interface ChatInputWrapperProps {
|
||||
onProvideFileAdder?: (adder: (files: File[]) => void) => void;
|
||||
messagePanelRef?: React.RefObject<HTMLDivElement | null>;
|
||||
onTyping?: () => void;
|
||||
onStopTyping?: () => void;
|
||||
}
|
||||
|
||||
export function ChatInputWrapper(
|
||||
@@ -37,7 +38,8 @@ export function ChatInputWrapper(
|
||||
onCloseEdit,
|
||||
onProvideFileAdder,
|
||||
messagePanelRef,
|
||||
onTyping
|
||||
onTyping,
|
||||
onStopTyping
|
||||
}: ChatInputWrapperProps
|
||||
) {
|
||||
const [message, setMessage] = useState("");
|
||||
@@ -124,6 +126,8 @@ export function ChatInputWrapper(
|
||||
setMessage("");
|
||||
setAttachmentsVisible(false);
|
||||
if (onClearReply) onClearReply();
|
||||
// Stop typing indicator when message is sent
|
||||
if (onStopTyping) onStopTyping();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -385,6 +385,14 @@ export function MessagePanelRenderer({ panel }: MessagePanelRendererProps) {
|
||||
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