refactor: add hook transform workspace (#1407)

This commit is contained in:
Himself65
2023-03-08 00:21:01 -06:00
committed by GitHub
parent f172831733
commit b8e45d059c
10 changed files with 176 additions and 166 deletions
+3 -1
View File
@@ -1,6 +1,6 @@
import { createJSONStorage } from 'jotai/utils';
import React from 'react';
import { preload } from 'swr';
import { mutate, preload } from 'swr';
import { z } from 'zod';
import { createAffineProviders } from '../../blocksuite';
@@ -65,6 +65,7 @@ export const AffinePlugin: WorkspacePlugin<RemWorkspaceFlavour.AFFINE> = {
blockSuiteWorkspace.doc
);
const { id } = await apis.createWorkspace(new Blob([binary.buffer]));
await mutate(matcher => matcher === QueryKey.getWorkspaces);
// refresh the local storage
await AffinePlugin.CRUD.list();
return id;
@@ -83,6 +84,7 @@ export const AffinePlugin: WorkspacePlugin<RemWorkspaceFlavour.AFFINE> = {
await apis.deleteWorkspace({
id: workspace.id,
});
await mutate(matcher => matcher === QueryKey.getWorkspaces);
},
get: async workspaceId => {
try {