mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-22 20:46:38 +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:
@@ -20,6 +20,7 @@ import {
|
||||
IndexedDBDocStorage,
|
||||
IndexedDBDocSyncStorage,
|
||||
IndexedDBIndexerStorage,
|
||||
IndexedDBIndexerSyncStorage,
|
||||
} from '@affine/nbstore/idb';
|
||||
import {
|
||||
IndexedDBV1BlobStorage,
|
||||
@@ -31,6 +32,7 @@ import {
|
||||
SqliteDocStorage,
|
||||
SqliteDocSyncStorage,
|
||||
SqliteIndexerStorage,
|
||||
SqliteIndexerSyncStorage,
|
||||
} from '@affine/nbstore/sqlite';
|
||||
import {
|
||||
SqliteV1BlobStorage,
|
||||
@@ -136,6 +138,9 @@ class CloudWorkspaceFlavourProvider implements WorkspaceFlavourProvider {
|
||||
BUILD_CONFIG.isElectron || BUILD_CONFIG.isIOS || BUILD_CONFIG.isAndroid
|
||||
? SqliteIndexerStorage
|
||||
: IndexedDBIndexerStorage;
|
||||
IndexerSyncStorageType = BUILD_CONFIG.isElectron
|
||||
? SqliteIndexerSyncStorage
|
||||
: IndexedDBIndexerSyncStorage;
|
||||
|
||||
async deleteWorkspace(id: string): Promise<void> {
|
||||
await this.graphqlService.gql({
|
||||
@@ -495,7 +500,7 @@ class CloudWorkspaceFlavourProvider implements WorkspaceFlavourProvider {
|
||||
},
|
||||
},
|
||||
indexerSync: {
|
||||
name: 'IndexedDBIndexerSyncStorage',
|
||||
name: this.IndexerSyncStorageType.identifier,
|
||||
opts: {
|
||||
flavour: this.flavour,
|
||||
type: 'workspace',
|
||||
|
||||
@@ -11,6 +11,7 @@ import {
|
||||
IndexedDBDocStorage,
|
||||
IndexedDBDocSyncStorage,
|
||||
IndexedDBIndexerStorage,
|
||||
IndexedDBIndexerSyncStorage,
|
||||
} from '@affine/nbstore/idb';
|
||||
import {
|
||||
IndexedDBV1BlobStorage,
|
||||
@@ -22,6 +23,7 @@ import {
|
||||
SqliteDocStorage,
|
||||
SqliteDocSyncStorage,
|
||||
SqliteIndexerStorage,
|
||||
SqliteIndexerSyncStorage,
|
||||
} from '@affine/nbstore/sqlite';
|
||||
import {
|
||||
SqliteV1BlobStorage,
|
||||
@@ -113,6 +115,9 @@ class LocalWorkspaceFlavourProvider implements WorkspaceFlavourProvider {
|
||||
BUILD_CONFIG.isElectron || BUILD_CONFIG.isIOS || BUILD_CONFIG.isAndroid
|
||||
? SqliteIndexerStorage
|
||||
: IndexedDBIndexerStorage;
|
||||
IndexerSyncStorageType = BUILD_CONFIG.isElectron
|
||||
? SqliteIndexerSyncStorage
|
||||
: IndexedDBIndexerSyncStorage;
|
||||
|
||||
async deleteWorkspace(id: string): Promise<void> {
|
||||
setLocalWorkspaceIds(ids => ids.filter(x => x !== id));
|
||||
@@ -365,7 +370,7 @@ class LocalWorkspaceFlavourProvider implements WorkspaceFlavourProvider {
|
||||
},
|
||||
},
|
||||
indexerSync: {
|
||||
name: 'IndexedDBIndexerSyncStorage',
|
||||
name: this.IndexerSyncStorageType.identifier,
|
||||
opts: {
|
||||
flavour: this.flavour,
|
||||
type: 'workspace',
|
||||
|
||||
Reference in New Issue
Block a user