fix(dashboard): account history reloads without a script error

The account page throttled its account_notes watcher around the check
of which account changed, but a throttled call gets no event, so every
change threw "Cannot read properties of undefined (reading 'id')" and
the history never reloaded. The check now runs first and only the
reload is throttled.

Check: lock or unlock an account (or add a note from another tab): the
history list on its page updates, and the browser console shows no
error.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Aaron Kimbrell
2026-09-29 02:01:43 -05:00
parent c70b163701
commit 1c1bf38431

View File

@@ -592,7 +592,11 @@ if (document.getElementById('noteForm')) {
if (del && confirm('Delete this entry from the history?')) api.action('/api/account_notes/' + del.dataset.deleteNote + '/delete', {}).then(loadNotes).catch(function () {});
});
loadNotes();
if (window.Live) Live.on('account_notes', Live.throttle(function (e) { if (!e.id || e.id === String(accountId)) loadNotes(); }, 1000));
// Only changes to this account's history; throttled after that check, since a throttled call gets no event
if (window.Live) {
var reloadNotes = Live.throttle(loadNotes, 1000);
Live.on('account_notes', function (e) { if (!e.id || String(e.id) === String(accountId)) reloadNotes(); });
}
}
function toggleLock(locked) {
if (!confirm((locked ? 'Lock' : 'Unlock') + ' this account?')) return;