feat(core): move enable ai to feature flag (#8195)

This commit is contained in:
EYHN
2024-09-11 07:42:07 +00:00
parent 8c191e6baa
commit 498a69af53
15 changed files with 109 additions and 78 deletions
@@ -1,10 +1,14 @@
import { distinctUntilChanged, skip } from 'rxjs';
import { OnEvent, Service } from '../../../framework';
import { ApplicationStarted } from '../../lifecycle';
import type { Workspace } from '../../workspace';
import { WorkspaceInitialized } from '../../workspace/events';
import { AFFINE_FLAGS } from '../constant';
import { Flags, type FlagsExt } from '../entities/flags';
@OnEvent(WorkspaceInitialized, e => e.setupBlocksuiteEditorFlags)
@OnEvent(ApplicationStarted, e => e.setupRestartListener)
export class FeatureFlagService extends Service {
flags = this.framework.createEntity(Flags) as FlagsExt;
@@ -18,4 +22,13 @@ export class FeatureFlagService extends Service {
}
}
}
setupRestartListener() {
this.flags.enable_ai.$.pipe(distinctUntilChanged(), skip(1)).subscribe(
() => {
// when enable_ai flag changes, reload the page.
window.location.reload();
}
);
}
}