From 6a8e685561b79010b01d146464eb850cdeb89e96 Mon Sep 17 00:00:00 2001 From: Alexander Zinchuk Date: Thu, 28 Dec 2023 14:38:16 +0100 Subject: [PATCH] Composer: Fix problem with scheduled messages (#4136) --- src/components/common/Composer.tsx | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/components/common/Composer.tsx b/src/components/common/Composer.tsx index 352681b5c..f4e1468d7 100644 --- a/src/components/common/Composer.tsx +++ b/src/components/common/Composer.tsx @@ -941,6 +941,8 @@ const Composer: FC = ({ if (currentAttachments.length) { sendAttachments({ attachments: currentAttachments, + scheduledAt, + isSilent, }); return; } @@ -1350,9 +1352,8 @@ const Composer: FC = ({ if (!currentMessageList) { return; } - requestCalendar((scheduledAt) => { - handleMessageSchedule({}, scheduledAt, currentMessageList!); + handleMessageSchedule({}, scheduledAt, currentMessageList); }); break; default: @@ -1460,10 +1461,16 @@ const Composer: FC = ({ sendSilent({ sendCompressed, sendGrouped }); }); - const onSend = mainButtonState === MainButtonState.Edit - ? handleEditComplete - : mainButtonState === MainButtonState.Schedule ? handleSendScheduled - : handleSend; + const onSend = useMemo(() => { + switch (mainButtonState) { + case MainButtonState.Edit: + return handleEditComplete; + case MainButtonState.Schedule: + return handleSendScheduled; + default: + return handleSend; + } + }, [mainButtonState, handleEditComplete]); const withBotCommands = isChatWithBot && botMenuButton?.type === 'commands' && !editingMessage && botCommands !== false && !activeVoiceRecording;