Fix endless animation if recaption is aborted

This commit is contained in:
Cohee 2024-06-30 19:20:39 +03:00
parent 67d2bb9891
commit 8ce2af16fb

View File

@ -520,12 +520,17 @@ jQuery(async function () {
const messageImg = messageBlock.find('.mes_img'); const messageImg = messageBlock.find('.mes_img');
if (messageImg.hasClass(animationClass)) return; if (messageImg.hasClass(animationClass)) return;
messageImg.addClass(animationClass); messageImg.addClass(animationClass);
const index = Number(messageBlock.attr('mesid')); try {
const data = getContext().chat[index]; const index = Number(messageBlock.attr('mesid'));
await captionExistingMessage(data); const data = getContext().chat[index];
appendMediaToMessage(data, messageBlock, false); await captionExistingMessage(data);
await saveChatConditional(); appendMediaToMessage(data, messageBlock, false);
messageImg.removeClass(animationClass); await saveChatConditional();
} catch(e) {
console.error('Message image recaption failed', e);
} finally {
messageImg.removeClass(animationClass);
}
}); });
SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'caption', SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'caption',