Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

fix: public workspace state (#1366)

Himself65e0dd94ae41f5
diff --git a/apps/web/src/hooks/affine/use-toggle-workspace-publish.ts b/apps/web/src/hooks/affine/use-toggle-workspace-publish.ts
index c7c3998ed2..b297725de6 100644
--- a/apps/web/src/hooks/affine/use-toggle-workspace-publish.ts
+++ b/apps/web/src/hooks/affine/use-toggle-workspace-publish.ts
@@ -1,5 +1,5 @@
import { useCallback } from 'react';
-import { mutate } from 'swr';
+import useSWR from 'swr';
import { jotaiStore, jotaiWorkspacesAtom } from '../../atoms';
import { QueryKey } from '../../plugins/affine/fetcher';
@@ -7,6 +7,7 @@ import { AffineWorkspace } from '../../shared';
import { apis } from '../../shared/apis';
export function useToggleWorkspacePublish(workspace: AffineWorkspace) {
+ const { mutate } = useSWR(QueryKey.getWorkspaces);
return useCallback(
async (isPublish: boolean) => {
await apis.updateWorkspace({
@@ -19,6 +20,6 @@ export function useToggleWorkspacePublish(workspace: AffineWorkspace) {
...jotaiStore.get(jotaiWorkspacesAtom),
]);
},
- [workspace]
+ [mutate, workspace.id]
);
}