mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-14 00:26:51 +08:00
99332228da
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **New Features**
* Added indexed clock management capabilities for documents, enabling
get, set, and clear operations across Android, iOS, Electron, and web
platforms.
* **Refactor**
* Improved storage architecture to dynamically select platform-specific
implementations (SQLite for Electron, IndexedDB for others).
* **Bug Fixes**
* Enhanced document operations to properly maintain and clean up indexer
synchronization state during document lifecycle changes.
<sub>✏️ Tip: You can customize this high-level summary in your review
settings.</sub>
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
39 lines
1017 B
TypeScript
39 lines
1017 B
TypeScript
import { share } from '../../connection';
|
|
import {
|
|
type DocIndexedClock,
|
|
IndexerSyncStorageBase,
|
|
} from '../../storage/indexer-sync';
|
|
import { NativeDBConnection, type SqliteNativeDBOptions } from './db';
|
|
|
|
export class SqliteIndexerSyncStorage extends IndexerSyncStorageBase {
|
|
static readonly identifier = 'SqliteIndexerSyncStorage';
|
|
|
|
override connection = share(new NativeDBConnection(this.options));
|
|
|
|
constructor(private readonly options: SqliteNativeDBOptions) {
|
|
super();
|
|
}
|
|
|
|
private get db() {
|
|
return this.connection.apis;
|
|
}
|
|
|
|
override async getDocIndexedClock(
|
|
docId: string
|
|
): Promise<DocIndexedClock | null> {
|
|
return this.db.getDocIndexedClock(docId);
|
|
}
|
|
|
|
override async setDocIndexedClock(clock: DocIndexedClock): Promise<void> {
|
|
await this.db.setDocIndexedClock(
|
|
clock.docId,
|
|
clock.timestamp,
|
|
clock.indexerVersion
|
|
);
|
|
}
|
|
|
|
override async clearDocIndexedClock(docId: string): Promise<void> {
|
|
await this.db.clearDocIndexedClock(docId);
|
|
}
|
|
}
|