必要な時以外はストレージを更新しない

This commit is contained in:
tamaina 2021-12-29 16:13:42 +09:00
parent 40abe3d907
commit 54bf280874

View file

@ -80,8 +80,10 @@ export class Storage<T extends StateDef> {
this.reactiveState[key].value = value; this.reactiveState[key].value = value;
const cache = JSON.parse(localStorage.getItem(this.keyForLocalStorage + '::cache::' + $i.id) || '{}'); const cache = JSON.parse(localStorage.getItem(this.keyForLocalStorage + '::cache::' + $i.id) || '{}');
if (cache[key] !== value) {
cache[key] = value; cache[key] = value;
localStorage.setItem(this.keyForLocalStorage + '::cache::' + $i.id, JSON.stringify(cache)); localStorage.setItem(this.keyForLocalStorage + '::cache::' + $i.id, JSON.stringify(cache));
}
}); });
} }
} }