mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-08 12:45:55 +08:00
feat(core): move enable ai to feature flag (#8195)
This commit is contained in:
@@ -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();
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user