diff --git a/packages/frontend/core/src/desktop/pages/upgrade-success/index.tsx b/packages/frontend/core/src/desktop/pages/upgrade-success/index.tsx
index db9b96951b..1af69dbe30 100644
--- a/packages/frontend/core/src/desktop/pages/upgrade-success/index.tsx
+++ b/packages/frontend/core/src/desktop/pages/upgrade-success/index.tsx
@@ -23,6 +23,8 @@ export const Component = () => {
} else {
jumpToIndex();
}
+ // close popup window
+ window.close();
}, [jumpToIndex, jumpToOpenInApp, params]);
const subtitle = (
diff --git a/packages/frontend/core/src/desktop/pages/upgrade-success/team/index.tsx b/packages/frontend/core/src/desktop/pages/upgrade-success/team/index.tsx
index f06200865a..88021ddc9f 100644
--- a/packages/frontend/core/src/desktop/pages/upgrade-success/team/index.tsx
+++ b/packages/frontend/core/src/desktop/pages/upgrade-success/team/index.tsx
@@ -1,10 +1,7 @@
import { Button } from '@affine/component';
import { AuthPageContainer } from '@affine/component/auth-components';
-import { getSubscriptionInfo } from '@affine/core/components/hooks/affine/use-subscription-notify';
-import { useNavigateHelper } from '@affine/core/components/hooks/use-navigate-helper';
import { Trans, useI18n } from '@affine/i18n';
import { useCallback } from 'react';
-import { useSearchParams } from 'react-router-dom';
import * as styles from './styles.css';
@@ -15,27 +12,11 @@ import * as styles from './styles.css';
*/
export const Component = () => {
const t = useI18n();
- const [params] = useSearchParams();
- const subscriptionInfo = getSubscriptionInfo(params);
- const { jumpToPage, jumpToOpenInApp, jumpToIndex } = useNavigateHelper();
const openWorkspace = useCallback(() => {
- if (params.get('schema')) {
- jumpToOpenInApp('bring-to-front');
- } else {
- if (subscriptionInfo.workspaceId) {
- jumpToPage(subscriptionInfo.workspaceId, 'all');
- return;
- }
- jumpToIndex();
- }
- }, [
- jumpToIndex,
- jumpToOpenInApp,
- jumpToPage,
- params,
- subscriptionInfo.workspaceId,
- ]);
+ // close popup window
+ window.close();
+ }, []);
const subtitle = (
diff --git a/packages/frontend/core/src/desktop/pages/upgrade-to-team/index.tsx b/packages/frontend/core/src/desktop/pages/upgrade-to-team/index.tsx
index 17d2f72446..776d8c0f5b 100644
--- a/packages/frontend/core/src/desktop/pages/upgrade-to-team/index.tsx
+++ b/packages/frontend/core/src/desktop/pages/upgrade-to-team/index.tsx
@@ -14,6 +14,7 @@ import {
import { AuthPageContainer } from '@affine/component/auth-components';
import { useSignOut } from '@affine/core/components/hooks/affine/use-sign-out';
import { useAsyncCallback } from '@affine/core/components/hooks/affine-async-hooks';
+import { useNavigateHelper } from '@affine/core/components/hooks/use-navigate-helper';
import { useWorkspaceInfo } from '@affine/core/components/hooks/use-workspace-info';
import { PureWorkspaceCard } from '@affine/core/components/workspace-selector/workspace-card';
import { AuthService } from '@affine/core/modules/cloud';
@@ -27,7 +28,7 @@ import { SubscriptionPlan, SubscriptionRecurring } from '@affine/graphql';
import { type I18nString, Trans, useI18n } from '@affine/i18n';
import { DoneIcon, NewPageIcon, SignOutIcon } from '@blocksuite/icons/rc';
import { useLiveData, useService } from '@toeverything/infra';
-import { useCallback, useMemo, useState } from 'react';
+import { useCallback, useEffect, useMemo, useState } from 'react';
import { useSearchParams } from 'react-router-dom';
import { Upgrade } from '../../dialogs/setting/general-setting/plans/plan-card';
@@ -142,8 +143,7 @@ export const UpgradeToTeam = ({ recurring }: { recurring: string | null }) => {
recurring={recurring}
open={openUpgrade}
onOpenChange={setOpenUpgrade}
- workspaceName={name}
- workspaceId={selectedWorkspace?.id ?? ''}
+ selectedWorkspace={selectedWorkspace}
/>
{
const UpgradeDialog = ({
open,
onOpenChange,
- workspaceName,
- workspaceId,
+ selectedWorkspace,
recurring,
}: {
open: boolean;
- workspaceName: string;
- workspaceId: string;
+ selectedWorkspace: WorkspaceMetadata | null;
recurring: string | null;
onOpenChange: (open: boolean) => void;
}) => {
const t = useI18n();
+ const workspacesService = useService(WorkspacesService);
+ const { jumpToPage } = useNavigateHelper();
+
+ const profile = selectedWorkspace
+ ? workspacesService.getProfile(selectedWorkspace)
+ : undefined;
+ const workspaceInfo = useLiveData(profile?.profile$);
+ const isTeam = workspaceInfo?.isTeam;
+ const workspaceName = workspaceInfo?.name;
+ const workspaceId = selectedWorkspace?.id;
+
const onClose = useCallback(() => {
onOpenChange(false);
}, [onOpenChange]);
+ const revalidate = useCallback(() => {
+ profile?.revalidate();
+ }, [profile]);
+
+ useEffect(() => {
+ revalidate();
+ }, [selectedWorkspace, revalidate]);
+
+ useEffect(() => {
+ window.addEventListener('focus', revalidate);
+ return () => {
+ window.removeEventListener('focus', revalidate);
+ };
+ }, [revalidate]);
+
+ useEffect(() => {
+ if (isTeam && selectedWorkspace) {
+ onClose();
+ return jumpToPage(selectedWorkspace.id, 'all');
+ }
+ }, [isTeam, jumpToPage, onClose, selectedWorkspace]);
+
const currentRecurring =
recurring &&
recurring.toLowerCase() === SubscriptionRecurring.Yearly.toLowerCase()