feat: support disable legacy cloud (#2006)

This commit is contained in:
Himself65
2023-04-18 02:23:00 -05:00
committed by GitHub
parent 94063352f5
commit f6fb049ff2
11 changed files with 64 additions and 24 deletions

View File

@@ -1,4 +1,4 @@
import { prefixUrl } from '@affine/env';
import { config, prefixUrl } from '@affine/env';
import { initPage } from '@affine/env/blocksuite';
import { currentAffineUserAtom } from '@affine/workspace/affine/atom';
import {
@@ -78,6 +78,10 @@ export const AffinePlugin: WorkspacePlugin<WorkspaceFlavour.AFFINE> = {
loadPriority: LoadPriority.HIGH,
Events: {
'workspace:access': async () => {
if (!config.enableLegacyCloud) {
console.warn('Legacy cloud is disabled');
return;
}
const response = await affineAuth.generateToken(SignMethod.Google);
if (response) {
setLoginStorage(response);
@@ -88,6 +92,10 @@ export const AffinePlugin: WorkspacePlugin<WorkspaceFlavour.AFFINE> = {
}
},
'workspace:revoke': async () => {
if (!config.enableLegacyCloud) {
console.warn('Legacy cloud is disabled');
return;
}
rootStore.set(rootWorkspacesMetadataAtom, workspaces =>
workspaces.filter(
workspace => workspace.flavour !== WorkspaceFlavour.AFFINE