Update Refresh RPG Info buttons in index.js to call commitTrackerDataFromPriorMessage() before updateRPGData()
This commit is contained in:
@@ -42,7 +42,7 @@ import {
|
||||
setMusicPlayerContainer,
|
||||
clearSessionAvatarPrompts
|
||||
} from './src/core/state.js';
|
||||
import { loadSettings, saveSettings, saveChatData, loadChatData, updateMessageSwipeData } from './src/core/persistence.js';
|
||||
import { loadSettings, saveSettings, saveChatData, loadChatData, updateMessageSwipeData, commitTrackerDataFromPriorMessage } from './src/core/persistence.js';
|
||||
import { registerAllEvents } from './src/core/events.js';
|
||||
|
||||
// Generation & Parsing modules
|
||||
@@ -800,6 +800,17 @@ async function initUI() {
|
||||
// console.log('[RPG Companion] Extension is disabled. Please enable it in the Extensions tab.');
|
||||
return;
|
||||
}
|
||||
const currentChat = getContext().chat;
|
||||
let lastAssistantIndex = -1;
|
||||
for (let i = currentChat.length - 1; i >= 0; i--) {
|
||||
if (!currentChat[i].is_user && !currentChat[i].is_system) {
|
||||
lastAssistantIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (lastAssistantIndex !== -1) {
|
||||
commitTrackerDataFromPriorMessage(lastAssistantIndex);
|
||||
}
|
||||
await updateRPGData(renderUserStats, renderInfoBox, renderThoughts, renderInventory);
|
||||
});
|
||||
|
||||
@@ -808,6 +819,17 @@ async function initUI() {
|
||||
if (!extensionSettings.enabled) {
|
||||
return;
|
||||
}
|
||||
const currentChat = getContext().chat;
|
||||
let lastAssistantIndex = -1;
|
||||
for (let i = currentChat.length - 1; i >= 0; i--) {
|
||||
if (!currentChat[i].is_user && !currentChat[i].is_system) {
|
||||
lastAssistantIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (lastAssistantIndex !== -1) {
|
||||
commitTrackerDataFromPriorMessage(lastAssistantIndex);
|
||||
}
|
||||
await updateRPGData(renderUserStats, renderInfoBox, renderThoughts, renderInventory);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user