mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-08 12:45:55 +08:00
feat(native): native reader for indexer (#14055)
This commit is contained in:
@@ -176,6 +176,21 @@ export class IndexedDBIndexerStorage extends IndexerStorageBase {
|
||||
this.emitTableUpdated(table);
|
||||
}
|
||||
|
||||
override async refreshIfNeed(): Promise<void> {
|
||||
const needRefreshTable = Object.entries(this.pendingUpdates)
|
||||
.filter(
|
||||
([, updates]) =>
|
||||
updates.deleteByQueries.length > 0 ||
|
||||
updates.deletes.length > 0 ||
|
||||
updates.inserts.length > 0 ||
|
||||
updates.updates.length > 0
|
||||
)
|
||||
.map(([table]) => table as keyof IndexerSchema);
|
||||
for (const table of needRefreshTable) {
|
||||
await this.refresh(table);
|
||||
}
|
||||
}
|
||||
|
||||
private watchTableUpdated(table: keyof IndexerSchema) {
|
||||
return new Observable(subscriber => {
|
||||
const listener = (ev: MessageEvent) => {
|
||||
|
||||
Reference in New Issue
Block a user