From 7def85a1740af7cb89307c34b3f632477d089136 Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Tue, 25 Feb 2025 21:21:59 +0200 Subject: [PATCH] Add couple of extra type checks --- public/script.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/script.js b/public/script.js index f0cf0ef80..f1049c7c9 100644 --- a/public/script.js +++ b/public/script.js @@ -6099,7 +6099,7 @@ export function syncMesToSwipe(messageId = null) { } const targetMessageId = messageId ?? chat.length - 1; - if (chat.length > targetMessageId) { + if (chat.length > targetMessageId || targetMessageId < 0) { console.warn(`[syncMesToSwipe] Invalid message ID: ${messageId}`); return false; } @@ -6120,7 +6120,7 @@ export function syncMesToSwipe(messageId = null) { } const targetSwipeInfo = targetMessage.swipe_info[targetMessage.swipe_id]; - if (typeof targetSwipeInfo !== 'object') { + if (!targetSwipeInfo || typeof targetSwipeInfo !== 'object') { return false; }