fix(electron): export and import (#9767)

This commit is contained in:
forehalo
2025-01-20 08:48:03 +00:00
parent 2e18ae59e3
commit cb53baca89
26 changed files with 332 additions and 453 deletions

View File

@@ -120,6 +120,7 @@ class CloudWorkspaceFlavourProvider implements WorkspaceFlavourProvider {
id: id,
},
});
// TODO(@forehalo): when deleting cloud workspace, should we delete the workspace folder in local?
this.revalidate();
await this.waitForLoaded();
}

View File

@@ -1,5 +1,9 @@
import { DebugLogger } from '@affine/debug';
import type { BlobStorage, DocStorage } from '@affine/nbstore';
import {
type BlobStorage,
type DocStorage,
universalId,
} from '@affine/nbstore';
import {
IndexedDBBlobStorage,
IndexedDBDocStorage,
@@ -101,11 +105,13 @@ class LocalWorkspaceFlavourProvider implements WorkspaceFlavourProvider {
async deleteWorkspace(id: string): Promise<void> {
setLocalWorkspaceIds(ids => ids.filter(x => x !== id));
// TODO(@forehalo): deleting logic for indexeddb workspaces
if (BUILD_CONFIG.isElectron) {
const electronApi = this.framework.get(DesktopApiService);
await electronApi.handler.workspace.delete(id);
await electronApi.handler.workspace.moveToTrash(
universalId({ peer: 'local', type: 'workspace', id })
);
}
// notify all browser tabs, so they can update their workspace list
this.notifyChannel.postMessage(id);
}