Fix syncMesToSwipe checks Ported from #3634

ca14352972664d396d764755fad1fd7fb68a968b

Cohee <18619528+Cohee1207@users.noreply.github.com>

1 files changed, +5 -1Ignore whitespace
public/script.js+5 -1
@@ -6148,13 +6148,17 @@ export function syncMesToSwipe(messageId = null) {
6148 }6148 }
61496149
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 }
61556155
6156 const targetMessage = chat[targetMessageId];6156 const targetMessage = chat[targetMessageId];
61576157
6158 if (!targetMessage) {
6159 return false;
6160 }
6161
6158 // No swipe data there yet, exit out6162 // 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;