diff --git a/.github/workflows/release-desktop.yml b/.github/workflows/release-desktop.yml index 2a9b32ca0adb3..9810136d41665 100644 --- a/.github/workflows/release-desktop.yml +++ b/.github/workflows/release-desktop.yml @@ -146,7 +146,6 @@ jobs: env: SKIP_WEB_BUILD: 1 HOIST_NODE_MODULES: 1 - DEBUG: '*' - name: signing DMG if: ${{ matrix.spec.platform == 'darwin' }} diff --git a/packages/frontend/core/src/components/sign-in/add-selfhosted.tsx b/packages/frontend/core/src/components/sign-in/add-selfhosted.tsx index b6db8a15a0b51..d993681d56d6e 100644 --- a/packages/frontend/core/src/components/sign-in/add-selfhosted.tsx +++ b/packages/frontend/core/src/components/sign-in/add-selfhosted.tsx @@ -78,9 +78,11 @@ export const AddSelfhostedStep = ({ ...prev, initialServerBaseUrl: undefined, })); - onConnect(); + if (serversService.getServerByBaseUrl(state.initialServerBaseUrl)) { + onConnect(); + } } - }, [changeState, onConnect, state]); + }, [changeState, onConnect, serversService, state]); return ( <> diff --git a/packages/frontend/core/src/components/sign-in/index.tsx b/packages/frontend/core/src/components/sign-in/index.tsx index e5ac4a9a7a66d..3bcb0ef07abfc 100644 --- a/packages/frontend/core/src/components/sign-in/index.tsx +++ b/packages/frontend/core/src/components/sign-in/index.tsx @@ -1,4 +1,5 @@ import { DefaultServerService, type Server } from '@affine/core/modules/cloud'; +import type { AuthSessionStatus } from '@affine/core/modules/cloud/entities/session'; import { FrameworkScope, useService } from '@toeverything/infra'; import { useState } from 'react'; @@ -22,11 +23,13 @@ export interface SignInState { } export const SignInPanel = ({ - onClose, + onSkip, server: initialServerBaseUrl, initStep, + onAuthenticated, }: { - onClose: () => void; + onAuthenticated?: (status: AuthSessionStatus) => void; + onSkip: () => void; server?: string; initStep?: SignInStep | undefined; }) => { @@ -47,18 +50,23 @@ export const SignInPanel = ({ return ( {step === 'signIn' ? ( - + ) : step === 'signInWithEmail' ? ( ) : step === 'signInWithPassword' ? ( ) : step === 'addSelfhosted' ? ( diff --git a/packages/frontend/core/src/components/sign-in/sign-in-with-email.tsx b/packages/frontend/core/src/components/sign-in/sign-in-with-email.tsx index 7a99ecaa27975..5c190e6f6ebc2 100644 --- a/packages/frontend/core/src/components/sign-in/sign-in-with-email.tsx +++ b/packages/frontend/core/src/components/sign-in/sign-in-with-email.tsx @@ -8,6 +8,7 @@ import { import { Button } from '@affine/component/ui/button'; import { useAsyncCallback } from '@affine/core/components/hooks/affine-async-hooks'; import { AuthService, CaptchaService } from '@affine/core/modules/cloud'; +import type { AuthSessionStatus } from '@affine/core/modules/cloud/entities/session'; import { Unreachable } from '@affine/env/constant'; import { Trans, useI18n } from '@affine/i18n'; import { useLiveData, useService } from '@toeverything/infra'; @@ -27,11 +28,11 @@ import * as style from './style.css'; export const SignInWithEmailStep = ({ state, changeState, - close, + onAuthenticated, }: { state: SignInState; changeState: Dispatch>; - close: () => void; + onAuthenticated?: (status: AuthSessionStatus) => void; }) => { const initialSent = useRef(false); const [resendCountDown, setResendCountDown] = useState(0); @@ -66,13 +67,13 @@ export const SignInWithEmailStep = ({ useEffect(() => { if (loginStatus === 'authenticated') { - close(); notify.success({ title: t['com.affine.auth.toast.title.signed-in'](), message: t['com.affine.auth.toast.message.signed-in'](), }); } - }, [close, loginStatus, t]); + onAuthenticated?.(loginStatus); + }, [loginStatus, onAuthenticated, t]); const sendEmail = useAsyncCallback(async () => { if (isSending || (!verifyToken && needCaptcha)) return; diff --git a/packages/frontend/core/src/components/sign-in/sign-in-with-password.tsx b/packages/frontend/core/src/components/sign-in/sign-in-with-password.tsx index 30b00e1c5859f..f79ac964b52c8 100644 --- a/packages/frontend/core/src/components/sign-in/sign-in-with-password.tsx +++ b/packages/frontend/core/src/components/sign-in/sign-in-with-password.tsx @@ -11,6 +11,7 @@ import { CaptchaService, ServerService, } from '@affine/core/modules/cloud'; +import type { AuthSessionStatus } from '@affine/core/modules/cloud/entities/session'; import { Unreachable } from '@affine/env/constant'; import { ServerDeploymentType } from '@affine/graphql'; import { useI18n } from '@affine/i18n'; @@ -25,11 +26,11 @@ import * as styles from './style.css'; export const SignInWithPasswordStep = ({ state, changeState, - close, + onAuthenticated, }: { state: SignInState; changeState: Dispatch>; - close: () => void; + onAuthenticated?: (status: AuthSessionStatus) => void; }) => { const t = useI18n(); const authService = useService(AuthService); @@ -62,13 +63,13 @@ export const SignInWithPasswordStep = ({ useEffect(() => { if (loginStatus === 'authenticated') { - close(); notify.success({ title: t['com.affine.auth.toast.title.signed-in'](), message: t['com.affine.auth.toast.message.signed-in'](), }); } - }, [close, loginStatus, t]); + onAuthenticated?.(loginStatus); + }, [loginStatus, onAuthenticated, t]); const onSignIn = useAsyncCallback(async () => { if (isLoading || (!verifyToken && needCaptcha)) return; diff --git a/packages/frontend/core/src/components/sign-in/sign-in.tsx b/packages/frontend/core/src/components/sign-in/sign-in.tsx index 57d13924aa1cb..efbe5e2199773 100644 --- a/packages/frontend/core/src/components/sign-in/sign-in.tsx +++ b/packages/frontend/core/src/components/sign-in/sign-in.tsx @@ -3,6 +3,7 @@ import { AuthInput, ModalHeader } from '@affine/component/auth-components'; import { OAuth } from '@affine/core/components/affine/auth/oauth'; import { useAsyncCallback } from '@affine/core/components/hooks/affine-async-hooks'; import { AuthService, ServerService } from '@affine/core/modules/cloud'; +import type { AuthSessionStatus } from '@affine/core/modules/cloud/entities/session'; import { FeatureFlagService } from '@affine/core/modules/feature-flag'; import { ServerDeploymentType } from '@affine/graphql'; import { Trans, useI18n } from '@affine/i18n'; @@ -30,11 +31,13 @@ function validateEmail(email: string) { export const SignInStep = ({ state, changeState, - close, + onSkip, + onAuthenticated, }: { state: SignInState; changeState: Dispatch>; - close: () => void; + onSkip: () => void; + onAuthenticated?: (status: AuthSessionStatus) => void; }) => { const t = useI18n(); const serverService = useService(ServerService); @@ -61,13 +64,13 @@ export const SignInStep = ({ useEffect(() => { if (loginStatus === 'authenticated') { - close(); notify.success({ title: t['com.affine.auth.toast.title.signed-in'](), message: t['com.affine.auth.toast.message.signed-in'](), }); } - }, [close, loginStatus, t]); + onAuthenticated?.(loginStatus); + }, [loginStatus, onAuthenticated, t]); const onContinue = useAsyncCallback(async () => { if (!validateEmail(email)) { @@ -205,7 +208,7 @@ export const SignInStep = ({