fix: public workspace state (#1366)

This commit is contained in:
Himself65 2023-03-06 22:01:57 -06:00 committed by GitHub
parent 33fb20e5cb
commit e0dd94ae41
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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]
);
}