fix(dashboard): sync widget data and fix refresh on chat load
- Update onMessageReceived to populate extensionSettings.infoBoxData and characterThoughts for dashboard widgets - Update updateRPGData (separate mode) with same extensionSettings population - Add refreshDashboard() calls after data updates in both generation paths - Fix onCharacterChanged to populate extensionSettings from loaded chat data - Fix refreshDashboard() to use correct property name (registry not widgetRegistry) - Reduce mood and weather widget font sizes to fit in 1x1 layout This fixes Scene tab widgets not updating when receiving messages or loading chats from welcome screen.
This commit is contained in:
@@ -31,6 +31,9 @@ import { renderInfoBox } from '../rendering/infoBox.js';
|
||||
import { renderThoughts, updateChatThoughts } from '../rendering/thoughts.js';
|
||||
import { renderInventory } from '../rendering/inventory.js';
|
||||
|
||||
// Dashboard
|
||||
import { refreshDashboard } from '../dashboard/dashboardIntegration.js';
|
||||
|
||||
// Utils
|
||||
import { getSafeThumbnailUrl } from '../../utils/avatars.js';
|
||||
|
||||
@@ -99,17 +102,26 @@ export async function onMessageReceived(data) {
|
||||
// console.log('[RPG Companion] Parsing together mode response:', responseText);
|
||||
|
||||
const parsedData = parseResponse(responseText);
|
||||
console.log('[RPG Companion] Parsed data results:', {
|
||||
hasUserStats: !!parsedData.userStats,
|
||||
hasInfoBox: !!parsedData.infoBox,
|
||||
hasCharacterThoughts: !!parsedData.characterThoughts
|
||||
});
|
||||
|
||||
// Update stored data
|
||||
// Update stored data (both lastGeneratedData for old UI and extensionSettings for dashboard widgets)
|
||||
if (parsedData.userStats) {
|
||||
lastGeneratedData.userStats = parsedData.userStats;
|
||||
parseUserStats(parsedData.userStats);
|
||||
parseUserStats(parsedData.userStats); // Updates extensionSettings.userStats
|
||||
}
|
||||
if (parsedData.infoBox) {
|
||||
lastGeneratedData.infoBox = parsedData.infoBox;
|
||||
extensionSettings.infoBoxData = parsedData.infoBox; // Update for dashboard widgets
|
||||
console.log('[RPG Companion] Updated extensionSettings.infoBoxData:', extensionSettings.infoBoxData.substring(0, 100));
|
||||
}
|
||||
if (parsedData.characterThoughts) {
|
||||
lastGeneratedData.characterThoughts = parsedData.characterThoughts;
|
||||
extensionSettings.characterThoughts = parsedData.characterThoughts; // Update for dashboard widgets
|
||||
console.log('[RPG Companion] Updated extensionSettings.characterThoughts:', extensionSettings.characterThoughts.substring(0, 100));
|
||||
}
|
||||
|
||||
// Store RPG data for this specific swipe in the message's extra field
|
||||
@@ -160,12 +172,15 @@ export async function onMessageReceived(data) {
|
||||
|
||||
// console.log('[RPG Companion] Cleaned message, removed tracker code blocks');
|
||||
|
||||
// Render the updated data
|
||||
// Render the updated data (old panel UI)
|
||||
renderUserStats();
|
||||
renderInfoBox();
|
||||
renderThoughts();
|
||||
renderInventory();
|
||||
|
||||
// Refresh dashboard widgets (v2 dashboard)
|
||||
refreshDashboard();
|
||||
|
||||
// Save to chat metadata
|
||||
saveChatData();
|
||||
}
|
||||
@@ -209,12 +224,23 @@ export function onCharacterChanged() {
|
||||
// Commit tracker data from the last assistant message to initialize for this chat
|
||||
commitTrackerData();
|
||||
|
||||
// Populate extensionSettings for dashboard widgets from loaded chat data
|
||||
if (lastGeneratedData.infoBox) {
|
||||
extensionSettings.infoBoxData = lastGeneratedData.infoBox;
|
||||
}
|
||||
if (lastGeneratedData.characterThoughts) {
|
||||
extensionSettings.characterThoughts = lastGeneratedData.characterThoughts;
|
||||
}
|
||||
|
||||
// Re-render with the loaded data
|
||||
renderUserStats();
|
||||
renderInfoBox();
|
||||
renderThoughts();
|
||||
renderInventory();
|
||||
|
||||
// Refresh dashboard widgets (v2 dashboard)
|
||||
refreshDashboard();
|
||||
|
||||
// Update chat thought overlays
|
||||
updateChatThoughts();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user