Add reloadFromState() for clean engine reset on layout switch

This commit is contained in:
2026-08-03 14:24:35 +10:00
parent 69e72c6c7a
commit 986f97b49a
+12
View File
@@ -96,6 +96,18 @@ class Playlist {
return this.getConfig(); return this.getConfig();
} }
/* Re-read the persisted playlist config from state (used after a layout load
* swaps playlist.live.json) and do the same clean reset as setConfig. */
reloadFromState() {
const saved = this.state.getPlaylistConfig(Playlist.defaults());
this.cfg = Playlist.migrate({ ...Playlist.defaults(), ...saved });
for (const uid of [...this.active.keys()]) this.despawn(uid);
this.trackState.clear();
this.tick();
this.broadcast({ type: 'active', ghosts: this.activeSnapshot() });
return this.getConfig();
}
allGhosts() { return this.state.getGhosts().ghosts; } allGhosts() { return this.state.getGhosts().ghosts; }
/* Ghosts a track may use, minus those pinned as residents. */ /* Ghosts a track may use, minus those pinned as residents. */