Skip to content

Commit b455545

Browse files
author
CASTELLANA-SAHIR Amel
committed
Fix modal closing and history loss on tune creation
The storage watcher in History would trigger loadHistoricState() after every saveCurrentState() call, creating a feedback loop that could replace the entire state object. This caused two issues: - Pattern editor dialog closing unexpectedly during editing - Previously created custom tunes disappearing from the current state Add a guard to skip loading when the storage key matches the current key, which was just saved by saveCurrentState().
1 parent e5df725 commit b455545

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

src/services/history.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@ export class History {
4848
));
4949

5050
watch(() => Number(this._storage.bbState) && this._storage[`bbState-${this._storage.bbState}`], () => {
51-
this.loadHistoricState(Number(this._storage.bbState));
51+
const key = Number(this._storage.bbState);
52+
if (key !== this.currentKey.value) {
53+
this.loadHistoricState(key);
54+
}
5255
}, { deep: true, immediate: true });
5356

5457
watch(this._compressedState, () => {

0 commit comments

Comments
 (0)