feat(electron): shared storage (#7492)

This commit is contained in:
EYHN
2024-07-15 03:21:08 +00:00
parent 0f1409756e
commit dca88e24fe
22 changed files with 411 additions and 15 deletions
+9 -1
View File
@@ -20,6 +20,12 @@ export interface Memento {
export class MemoryMemento implements Memento {
private readonly data = new Map<string, LiveData<any>>();
setAll(init: Record<string, any>) {
for (const [key, value] of Object.entries(init)) {
this.set(key, value);
}
}
private getLiveData(key: string): LiveData<any> {
let data$ = this.data.get(key);
if (!data$) {
@@ -39,7 +45,9 @@ export class MemoryMemento implements Memento {
this.getLiveData(key).next(value);
}
keys(): string[] {
return Array.from(this.data.keys());
return Array.from(this.data)
.filter(([_, v$]) => v$.value !== undefined)
.map(([k]) => k);
}
clear(): void {
this.data.clear();