mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-17 22:37:04 +08:00
refactor!: next generation AFFiNE code structure (#1176)
This commit is contained in:
21
apps/web/src/hooks/affine/use-toggle-workspace-publish.ts
Normal file
21
apps/web/src/hooks/affine/use-toggle-workspace-publish.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { useCallback } from 'react';
|
||||
import { mutate } from 'swr';
|
||||
|
||||
import { QueryKey } from '../../plugins/affine/fetcher';
|
||||
import { AffineRemoteWorkspace } from '../../shared';
|
||||
import { apis } from '../../shared/apis';
|
||||
import { refreshDataCenter } from '../use-workspaces';
|
||||
|
||||
export function useToggleWorkspacePublish(workspace: AffineRemoteWorkspace) {
|
||||
return useCallback(
|
||||
async (isPublish: boolean) => {
|
||||
await apis.updateWorkspace({
|
||||
id: workspace.id,
|
||||
public: isPublish,
|
||||
});
|
||||
await mutate(QueryKey.getWorkspaces);
|
||||
await refreshDataCenter();
|
||||
},
|
||||
[workspace]
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user