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