From e2a9f184272de59ad61ca5fac6914e9e099a25ee Mon Sep 17 00:00:00 2001 From: tesohi Date: Wed, 17 Jan 2024 17:27:04 +0400 Subject: [PATCH] [TH2-5155] Add ability to turn back to the attached message --- src/components/message/AttachedMessagesSelection.tsx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/components/message/AttachedMessagesSelection.tsx b/src/components/message/AttachedMessagesSelection.tsx index d0f8363f8..6a70512a2 100644 --- a/src/components/message/AttachedMessagesSelection.tsx +++ b/src/components/message/AttachedMessagesSelection.tsx @@ -33,6 +33,11 @@ const AttachedMessagesSelection = () => { messagesStore.selectAttachedMessage(messagesStore.attachedMessages[nextIndex]); setMessageIndex(nextIndex); } + if (messageIndex === 0) { + const nextIndex = messagesStore.attachedMessages.length - 1; + messagesStore.selectAttachedMessage(messagesStore.attachedMessages[nextIndex]); + setMessageIndex(nextIndex); + } }; const onNext = () => { @@ -41,6 +46,10 @@ const AttachedMessagesSelection = () => { messagesStore.selectAttachedMessage(messagesStore.attachedMessages[nextIndex]); setMessageIndex(nextIndex); } + if (messageIndex === messagesStore.attachedMessages.length - 1) { + messagesStore.selectAttachedMessage(messagesStore.attachedMessages[0]); + setMessageIndex(0); + } }; if (messagesStore.attachedMessages.length === 0 || !messagesStore.dataStore.messages.length)