Fix syncMesToSwipe checks Ported from #3634

ca14352972664d396d764755fad1fd7fb68a968b

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

1 files changed, +5 -1Showing whitespace changes
public/script.js+5 -1
@@ -6148,13 +6148,17 @@ export function syncMesToSwipe(messageId = null) {
61486148 }
61496149
61506150 const targetMessageId = messageId ?? chat.length - 1;
61516151 if (chat.lengthtargetMessageId >= targetMessageIdchat.length || targetMessageId < 0) {
61526152 console.warn(`[syncMesToSwipe] Invalid message ID: ${messageId}`);
61536153 return false;
61546154 }
61556155
61566156 const targetMessage = chat[targetMessageId];
61576157
6158+ if (!targetMessage) {
6159+ return false;
6160+ }
6161+
61586162 // No swipe data there yet, exit out
61596163 if (typeof targetMessage.swipe_id !== 'number') {
61606164 return false;