| 6148 | } | 6148 | } |
| 6149 | | 6149 | |
| 6150 | const targetMessageId = messageId ?? chat.length - 1; | 6150 | const targetMessageId = messageId ?? chat.length - 1; |
| 6151 | if (chat.length > targetMessageId || targetMessageId < 0) { | 6151 | if (targetMessageId >= chat.length || targetMessageId < 0) { |
| 6152 | console.warn(`[syncMesToSwipe] Invalid message ID: ${messageId}`); | 6152 | console.warn(`[syncMesToSwipe] Invalid message ID: ${messageId}`); |
| 6153 | return false; | 6153 | return false; |
| 6154 | } | 6154 | } |
| 6155 | | 6155 | |
| 6156 | const targetMessage = chat[targetMessageId]; | 6156 | const targetMessage = chat[targetMessageId]; |
| 6157 | | 6157 | |
| | 6158 | if (!targetMessage) { |
| | 6159 | return false; |
| | 6160 | } |
| | 6161 | |
| 6158 | // No swipe data there yet, exit out | 6162 | // No swipe data there yet, exit out |
| 6159 | if (typeof targetMessage.swipe_id !== 'number') { | 6163 | if (typeof targetMessage.swipe_id !== 'number') { |
| 6160 | return false; | 6164 | return false; |