Properly handle cleared ref after unmount
This commit is contained in:
parent
810f2bdd65
commit
2e156d7ef4
@ -29,10 +29,10 @@ const useDraft = (
|
|||||||
|
|
||||||
const updateDraft = useCallback((draftChatId: string, draftThreadId: number) => {
|
const updateDraft = useCallback((draftChatId: string, draftThreadId: number) => {
|
||||||
const currentHtml = htmlRef.current;
|
const currentHtml = htmlRef.current;
|
||||||
if (editedMessage) return;
|
if (currentHtml === undefined || editedMessage) return;
|
||||||
if (currentHtml.length) {
|
if (currentHtml.length) {
|
||||||
saveDraft({ chatId: draftChatId, threadId: draftThreadId, draft: parseMessageInput(currentHtml!) });
|
saveDraft({ chatId: draftChatId, threadId: draftThreadId, draft: parseMessageInput(currentHtml!) });
|
||||||
} else if (currentHtml !== undefined) {
|
} else {
|
||||||
clearDraft({ chatId: draftChatId, threadId: draftThreadId });
|
clearDraft({ chatId: draftChatId, threadId: draftThreadId });
|
||||||
}
|
}
|
||||||
}, [clearDraft, editedMessage, htmlRef, saveDraft]);
|
}, [clearDraft, editedMessage, htmlRef, saveDraft]);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user