mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-12 15:46:29 +08:00
refactor(core): replace all notification relies on jotai (#6417)
- remove all notification that implemented with jotai and replaced with new `notify` - Add some notify presets: - `notify.error` - `notify.success` - `notify.warning`
This commit is contained in:
@@ -1,11 +1,10 @@
|
||||
import type { PasswordLimitsFragment } from '@affine/graphql';
|
||||
import { useAFFiNEI18N } from '@affine/i18n/hooks';
|
||||
import { useSetAtom } from 'jotai';
|
||||
import type { FC } from 'react';
|
||||
import { useCallback, useState } from 'react';
|
||||
|
||||
import { Button } from '../../ui/button';
|
||||
import { pushNotificationAtom } from '../notification-center';
|
||||
import { notify } from '../../ui/notification';
|
||||
import { AuthPageContainer } from './auth-page-container';
|
||||
import { SetPassword } from './set-password';
|
||||
import type { User } from './type';
|
||||
@@ -23,22 +22,19 @@ export const ChangePasswordPage: FC<{
|
||||
}) => {
|
||||
const t = useAFFiNEI18N();
|
||||
const [hasSetUp, setHasSetUp] = useState(false);
|
||||
const pushNotification = useSetAtom(pushNotificationAtom);
|
||||
|
||||
const onSetPassword = useCallback(
|
||||
(passWord: string) => {
|
||||
propsOnSetPassword(passWord)
|
||||
.then(() => setHasSetUp(true))
|
||||
.catch(e =>
|
||||
pushNotification({
|
||||
notify.error({
|
||||
title: t['com.affine.auth.password.set-failed'](),
|
||||
message: String(e),
|
||||
key: Date.now().toString(),
|
||||
type: 'error',
|
||||
})
|
||||
);
|
||||
},
|
||||
[propsOnSetPassword, t, pushNotification]
|
||||
[propsOnSetPassword, t]
|
||||
);
|
||||
|
||||
return (
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
import type { PasswordLimitsFragment } from '@affine/graphql';
|
||||
import { useAFFiNEI18N } from '@affine/i18n/hooks';
|
||||
import { useSetAtom } from 'jotai';
|
||||
import type { FC } from 'react';
|
||||
import { useCallback, useState } from 'react';
|
||||
|
||||
import { Button } from '../../ui/button';
|
||||
import { pushNotificationAtom } from '../notification-center';
|
||||
import { notify } from '../../ui/notification';
|
||||
import { AuthPageContainer } from './auth-page-container';
|
||||
import { SetPassword } from './set-password';
|
||||
import type { User } from './type';
|
||||
@@ -23,22 +22,19 @@ export const SetPasswordPage: FC<{
|
||||
}) => {
|
||||
const t = useAFFiNEI18N();
|
||||
const [hasSetUp, setHasSetUp] = useState(false);
|
||||
const pushNotification = useSetAtom(pushNotificationAtom);
|
||||
|
||||
const onSetPassword = useCallback(
|
||||
(passWord: string) => {
|
||||
propsOnSetPassword(passWord)
|
||||
.then(() => setHasSetUp(true))
|
||||
.catch(e =>
|
||||
pushNotification({
|
||||
notify.error({
|
||||
title: t['com.affine.auth.password.set-failed'](),
|
||||
message: String(e),
|
||||
key: Date.now().toString(),
|
||||
type: 'error',
|
||||
})
|
||||
);
|
||||
},
|
||||
[propsOnSetPassword, pushNotification, t]
|
||||
[propsOnSetPassword, t]
|
||||
);
|
||||
|
||||
return (
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
import type { PasswordLimitsFragment } from '@affine/graphql';
|
||||
import { useAFFiNEI18N } from '@affine/i18n/hooks';
|
||||
import { useSetAtom } from 'jotai';
|
||||
import type { FC } from 'react';
|
||||
import { useCallback, useState } from 'react';
|
||||
|
||||
import { Button } from '../../ui/button';
|
||||
import { pushNotificationAtom } from '../notification-center';
|
||||
import { notify } from '../../ui/notification';
|
||||
import { AuthPageContainer } from './auth-page-container';
|
||||
import { SetPassword } from './set-password';
|
||||
import type { User } from './type';
|
||||
@@ -25,22 +24,19 @@ export const SignUpPage: FC<{
|
||||
}) => {
|
||||
const t = useAFFiNEI18N();
|
||||
const [hasSetUp, setHasSetUp] = useState(false);
|
||||
const pushNotification = useSetAtom(pushNotificationAtom);
|
||||
|
||||
const onSetPassword = useCallback(
|
||||
(passWord: string) => {
|
||||
propsOnSetPassword(passWord)
|
||||
.then(() => setHasSetUp(true))
|
||||
.catch(e =>
|
||||
pushNotification({
|
||||
notify.error({
|
||||
title: t['com.affine.auth.password.set-failed'](),
|
||||
message: String(e),
|
||||
key: Date.now().toString(),
|
||||
type: 'error',
|
||||
})
|
||||
);
|
||||
},
|
||||
[propsOnSetPassword, pushNotification, t]
|
||||
[propsOnSetPassword, t]
|
||||
);
|
||||
const onLater = useCallback(() => {
|
||||
setHasSetUp(true);
|
||||
|
||||
Reference in New Issue
Block a user