From b455545b99204a77f20a2489eeada02e559751a6 Mon Sep 17 00:00:00 2001 From: CASTELLANA-SAHIR Amel Date: Wed, 25 Mar 2026 21:36:39 +0100 Subject: [PATCH] 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(). --- src/services/history.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/services/history.ts b/src/services/history.ts index fa24864ed..c1700ebd3 100644 --- a/src/services/history.ts +++ b/src/services/history.ts @@ -48,7 +48,10 @@ export class History { )); watch(() => Number(this._storage.bbState) && this._storage[`bbState-${this._storage.bbState}`], () => { - this.loadHistoricState(Number(this._storage.bbState)); + const key = Number(this._storage.bbState); + if (key !== this.currentKey.value) { + this.loadHistoricState(key); + } }, { deep: true, immediate: true }); watch(this._compressedState, () => {