fix(core): unexpectedly jump to price plan when selfhosting (#10247)

This commit is contained in:
JimmFly
2025-02-19 15:01:54 +08:00
committed by GitHub
parent c0cc4224bb
commit 751f229e30

View File

@@ -13,6 +13,7 @@ import type {
WORKSPACE_DIALOG_SCHEMA,
} from '@affine/core/modules/dialogs/constant';
import { GlobalContextService } from '@affine/core/modules/global-context';
import { ServerDeploymentType } from '@affine/graphql';
import { Trans } from '@affine/i18n';
import { ContactWithUsIcon } from '@blocksuite/icons/rc';
import { FrameworkScope, useLiveData, useService } from '@toeverything/infra';
@@ -20,6 +21,7 @@ import { debounce } from 'lodash-es';
import {
Suspense,
useCallback,
useEffect,
useLayoutEffect,
useRef,
useState,
@@ -72,6 +74,11 @@ const SettingModalInner = ({
const loginStatus = useLiveData(
currentServer.scope.get(AuthService).session.status$
);
const isSelfhosted = useLiveData(
currentServer.config$.selector(
c => c.type === ServerDeploymentType.Selfhosted
)
);
const modalContentRef = useRef<HTMLDivElement>(null);
const modalContentWrapperRef = useRef<HTMLDivElement>(null);
@@ -133,6 +140,16 @@ const SettingModalInner = ({
setOpenStarAFFiNEModal(true);
}, [setOpenStarAFFiNEModal]);
useEffect(() => {
if (
isSelfhosted &&
(settingState.activeTab === 'plans' ||
settingState.activeTab === 'workspace:billing')
) {
setSettingState({ activeTab: 'workspace:license' });
}
}, [isSelfhosted, settingState.activeTab]);
return (
<FrameworkScope scope={currentServer.scope}>
<SettingSidebar