fix of #8512
https://github.com/misskey-dev/misskey/pull/8512#issuecomment-1368553870
This commit is contained in:
parent
605582f5f7
commit
fb364ce740
3 changed files with 38 additions and 26 deletions
|
|
@ -23,8 +23,13 @@ export class Storage<T extends StateDef> {
|
|||
// TODO: これが実装されたらreadonlyにしたい: https://github.com/microsoft/TypeScript/issues/37487
|
||||
public readonly state: { [K in keyof T]: T[K]['default'] };
|
||||
public readonly reactiveState: { [K in keyof T]: Ref<T[K]['default']> };
|
||||
public readonly ready: Promise<void>;
|
||||
private markAsReady: () => void = () => {};
|
||||
|
||||
constructor(key: string, def: T) {
|
||||
this.ready = new Promise((res) => {
|
||||
this.markAsReady = res;
|
||||
});
|
||||
this.key = key;
|
||||
this.keyForLocalStorage = 'pizzax::' + key;
|
||||
this.def = def;
|
||||
|
|
@ -72,6 +77,7 @@ export class Storage<T extends StateDef> {
|
|||
}
|
||||
}
|
||||
localStorage.setItem(this.keyForLocalStorage + '::cache::' + $i.id, JSON.stringify(cache));
|
||||
this.markAsReady();
|
||||
});
|
||||
}, 1);
|
||||
// streamingのuser storage updateイベントを監視して更新
|
||||
|
|
@ -87,6 +93,8 @@ export class Storage<T extends StateDef> {
|
|||
localStorage.setItem(this.keyForLocalStorage + '::cache::' + $i.id, JSON.stringify(cache));
|
||||
}
|
||||
});
|
||||
} else {
|
||||
this.markAsReady();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue