From 986f97b49ab43ad3d4cb9f4bf34b2f3c4e0f7360 Mon Sep 17 00:00:00 2001 From: jessikitty Date: Mon, 3 Aug 2026 14:24:35 +1000 Subject: [PATCH] Add reloadFromState() for clean engine reset on layout switch --- server/playlist.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/server/playlist.js b/server/playlist.js index 062a691..90395f3 100644 --- a/server/playlist.js +++ b/server/playlist.js @@ -96,6 +96,18 @@ class Playlist { 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; } /* Ghosts a track may use, minus those pinned as residents. */