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. */