mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-19 07:17:00 +08:00
feat: native sync state (#14190)
<!-- 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 -->
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import type { CrawlResult } from '@affine/nbstore';
|
||||
import type { CrawlResult, DocIndexedClock } from '@affine/nbstore';
|
||||
|
||||
export interface Blob {
|
||||
key: string;
|
||||
@@ -187,4 +187,18 @@ export interface NbStorePlugin {
|
||||
}) => Promise<{ matches: { start: number; end: number }[] }>;
|
||||
ftsFlushIndex: (options: { id: string }) => Promise<void>;
|
||||
ftsIndexVersion: () => Promise<{ indexVersion: number }>;
|
||||
getDocIndexedClock: (options: {
|
||||
id: string;
|
||||
docId: string;
|
||||
}) => Promise<DocIndexedClock | null>;
|
||||
setDocIndexedClock: (options: {
|
||||
id: string;
|
||||
docId: string;
|
||||
indexedClock: number;
|
||||
indexerVersion: number;
|
||||
}) => Promise<void>;
|
||||
clearDocIndexedClock: (options: {
|
||||
id: string;
|
||||
docId: string;
|
||||
}) => Promise<void>;
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import {
|
||||
type BlobRecord,
|
||||
type CrawlResult,
|
||||
type DocClock,
|
||||
type DocIndexedClock,
|
||||
type DocRecord,
|
||||
type ListedBlobRecord,
|
||||
parseUniversalId,
|
||||
@@ -415,4 +416,29 @@ export const NbStoreNativeDBApis: NativeDBApis = {
|
||||
ftsIndexVersion: function (): Promise<number> {
|
||||
return NbStore.ftsIndexVersion().then(res => res.indexVersion);
|
||||
},
|
||||
getDocIndexedClock: function (
|
||||
id: string,
|
||||
docId: string
|
||||
): Promise<DocIndexedClock | null> {
|
||||
return NbStore.getDocIndexedClock({ id, docId });
|
||||
},
|
||||
setDocIndexedClock: function (
|
||||
id: string,
|
||||
docId: string,
|
||||
indexedClock: Date,
|
||||
indexerVersion: number
|
||||
): Promise<void> {
|
||||
return NbStore.setDocIndexedClock({
|
||||
id,
|
||||
docId,
|
||||
indexedClock: indexedClock.getTime(),
|
||||
indexerVersion,
|
||||
});
|
||||
},
|
||||
clearDocIndexedClock: function (id: string, docId: string): Promise<void> {
|
||||
return NbStore.clearDocIndexedClock({
|
||||
id,
|
||||
docId,
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user