Add reloadFromState() for clean engine reset on layout switch
This commit is contained in:
@@ -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. */
|
||||
|
||||
Reference in New Issue
Block a user