Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

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

JimmFly751f229e305d
diff --git a/packages/frontend/core/src/desktop/dialogs/setting/index.tsx b/packages/frontend/core/src/desktop/dialogs/setting/index.tsx
index 67e18ce80c..922d7cb35a 100644
--- a/packages/frontend/core/src/desktop/dialogs/setting/index.tsx
+++ b/packages/frontend/core/src/desktop/dialogs/setting/index.tsx
@@ -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