mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 04:18:54 +00:00
feat(electron): shared storage (#7492)
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { Observable } from 'rxjs';
|
||||
import { from, merge, of, Subject, throttleTime } from 'rxjs';
|
||||
|
||||
import { exhaustMapWithTrailing } from '../../../../utils/exhaustmap-with-trailing';
|
||||
import { exhaustMapWithTrailing } from '../../../../utils/';
|
||||
import {
|
||||
type AggregateOptions,
|
||||
type AggregateResult,
|
||||
|
||||
@@ -4,7 +4,7 @@ import { merge, Observable, of, throttleTime } from 'rxjs';
|
||||
|
||||
import { fromPromise } from '../../../../livedata';
|
||||
import { throwIfAborted } from '../../../../utils';
|
||||
import { exhaustMapWithTrailing } from '../../../../utils/exhaustmap-with-trailing';
|
||||
import { exhaustMapWithTrailing } from '../../../../utils/';
|
||||
import type { Job, JobParams, JobQueue } from '../../';
|
||||
|
||||
interface IndexDB extends DBSchema {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
export * from './async-lock';
|
||||
export * from './async-queue';
|
||||
export * from './exhaustmap-with-trailing';
|
||||
export * from './merge-updates';
|
||||
export * from './object-pool';
|
||||
export * from './stable-hash';
|
||||
|
||||
Reference in New Issue
Block a user