Skip to content

Commit 749a037

Browse files
committed
fix: dashboard bugs - mergeObject, status indicator, activity log API
- Use foundry.utils.mergeObject instead of bare mergeObject (broken in v12+) - Status indicator click now opens dashboard instead of only reconnecting - Use SyncManager public API (logActivity, getActivityLog, clearActivityLog) instead of accessing private _activityLog array directly https://claude.ai/code/session_01XMwxFR8BCi5XvgaSVMSBZB
1 parent 6db6e20 commit 749a037

2 files changed

Lines changed: 7 additions & 18 deletions

File tree

foundry-module/scripts/module.mjs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,9 @@ function _addStatusIndicator() {
133133
syncManager.api.onStateChange(updateState);
134134
updateState();
135135

136-
// Click to reconnect when disconnected.
136+
// Click to open the sync dashboard.
137137
indicator.addEventListener('click', () => {
138-
const state = syncManager.api.state;
139-
if (state === 'disconnected') {
140-
syncManager.api.connect();
141-
}
138+
if (dashboard) dashboard.render(true);
142139
});
143140

144141
// Flash the dot briefly when a WS message arrives (activity indicator).

foundry-module/scripts/sync-dashboard.mjs

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export class SyncDashboard extends Application {
2929
}
3030

3131
static get defaultOptions() {
32-
return mergeObject(super.defaultOptions, {
32+
return foundry.utils.mergeObject(super.defaultOptions, {
3333
id: 'chronicle-sync-dashboard',
3434
title: 'Chronicle Sync',
3535
template: 'modules/chronicle-sync/templates/sync-dashboard.hbs',
@@ -431,7 +431,7 @@ export class SyncDashboard extends Application {
431431
*/
432432
_buildStatusData() {
433433
const state = this.api?.state ?? 'disconnected';
434-
const activityLog = this._syncManager?._activityLog ?? [];
434+
const activityLog = this._syncManager?.getActivityLog() ?? [];
435435

436436
// Compute stats from Foundry documents.
437437
const syncedEntities = game.journal.contents.filter(
@@ -448,7 +448,7 @@ export class SyncDashboard extends Application {
448448
lastSyncTime: getSetting('lastSyncTime') || 'Never',
449449
syncedEntities,
450450
linkedScenes,
451-
activityLog: activityLog.slice(-50).reverse(),
451+
activityLog: activityLog.slice(0, 50),
452452
};
453453
}
454454

@@ -598,9 +598,7 @@ export class SyncDashboard extends Application {
598598
});
599599

600600
html.find('[data-action="clear-log"]').on('click', () => {
601-
if (this._syncManager?._activityLog) {
602-
this._syncManager._activityLog = [];
603-
}
601+
this._syncManager?.clearActivityLog();
604602
this.render(false);
605603
});
606604

@@ -881,13 +879,7 @@ export class SyncDashboard extends Application {
881879
* @param {string} message
882880
*/
883881
_logActivity(type, message) {
884-
if (this._syncManager?._activityLog) {
885-
this._syncManager._activityLog.push({
886-
time: Date.now(),
887-
type,
888-
message,
889-
});
890-
}
882+
this._syncManager?.logActivity(type, message);
891883
}
892884

893885
/** Force refresh all data and re-render. */

0 commit comments

Comments
 (0)