mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-14 21:27:20 +00:00
feat(core): disable ai if value of sever copilot config is false (#10520)
Fix issue [AF-2224](https://linear.app/affine-design/issue/AF-2224).
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import { FeatureFlagService } from '@affine/core/modules/feature-flag';
|
||||
import { useService } from '@toeverything/infra';
|
||||
import { Suspense, useCallback, useEffect, useState } from 'react';
|
||||
|
||||
import { useEnableAI } from '../../hooks/affine/use-enable-ai';
|
||||
import { AIOnboardingEdgeless } from './edgeless.dialog';
|
||||
import { AIOnboardingLocal } from './local.dialog';
|
||||
import { AIOnboardingType } from './type';
|
||||
@@ -28,8 +27,7 @@ const useDismiss = (key: AIOnboardingType) => {
|
||||
|
||||
export const WorkspaceAIOnboarding = () => {
|
||||
const [dismissLocal] = useDismiss(AIOnboardingType.LOCAL);
|
||||
const featureFlagService = useService(FeatureFlagService);
|
||||
const enableAI = featureFlagService.flags.enable_ai.value;
|
||||
const enableAI = useEnableAI();
|
||||
|
||||
return (
|
||||
<Suspense>
|
||||
@@ -40,8 +38,7 @@ export const WorkspaceAIOnboarding = () => {
|
||||
|
||||
export const PageAIOnboarding = () => {
|
||||
const [dismissEdgeless] = useDismiss(AIOnboardingType.EDGELESS);
|
||||
const featureFlagService = useService(FeatureFlagService);
|
||||
const enableAI = featureFlagService.flags.enable_ai.value;
|
||||
const enableAI = useEnableAI();
|
||||
|
||||
return (
|
||||
<Suspense>
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
import { ServerService } from '@affine/core/modules/cloud';
|
||||
import { FeatureFlagService } from '@affine/core/modules/feature-flag';
|
||||
import { useLiveData, useService } from '@toeverything/infra';
|
||||
|
||||
export const useEnableAI = () => {
|
||||
const featureFlagService = useService(FeatureFlagService);
|
||||
const aiFeature = useLiveData(featureFlagService.flags.enable_ai.$);
|
||||
|
||||
const serverService = useService(ServerService);
|
||||
const serverConfig = useLiveData(serverService.server.features$);
|
||||
const aiConfig = serverConfig.copilot;
|
||||
|
||||
return aiFeature && aiConfig;
|
||||
};
|
||||
Reference in New Issue
Block a user