mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-13 12:55:00 +00: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,3 +1,4 @@
|
||||
import { notify } from '@affine/component';
|
||||
import {
|
||||
ChangeEmailPage,
|
||||
ChangePasswordPage,
|
||||
@@ -7,7 +8,6 @@ import {
|
||||
SignInSuccessPage,
|
||||
SignUpPage,
|
||||
} from '@affine/component/auth-components';
|
||||
import { pushNotificationAtom } from '@affine/component/notification-center';
|
||||
import { useCredentialsRequirement } from '@affine/core/hooks/affine/use-server-config';
|
||||
import {
|
||||
changeEmailMutation,
|
||||
@@ -17,7 +17,6 @@ import {
|
||||
verifyEmailMutation,
|
||||
} from '@affine/graphql';
|
||||
import { useAFFiNEI18N } from '@affine/i18n/hooks';
|
||||
import { useSetAtom } from 'jotai/react';
|
||||
import type { ReactElement } from 'react';
|
||||
import { useCallback } from 'react';
|
||||
import type { LoaderFunction } from 'react-router-dom';
|
||||
@@ -50,7 +49,6 @@ export const AuthPage = (): ReactElement | null => {
|
||||
|
||||
const { authType } = useParams();
|
||||
const [searchParams] = useSearchParams();
|
||||
const pushNotification = useSetAtom(pushNotificationAtom);
|
||||
|
||||
const { trigger: changePassword } = useMutation({
|
||||
mutation: changePasswordMutation,
|
||||
@@ -72,20 +70,18 @@ export const AuthPage = (): ReactElement | null => {
|
||||
|
||||
// FIXME: There is not notification
|
||||
if (res?.sendVerifyChangeEmail) {
|
||||
pushNotification({
|
||||
notify.success({
|
||||
title: t['com.affine.auth.sent.verify.email.hint'](),
|
||||
type: 'success',
|
||||
});
|
||||
} else {
|
||||
pushNotification({
|
||||
notify.error({
|
||||
title: t['com.affine.auth.sent.change.email.fail'](),
|
||||
type: 'error',
|
||||
});
|
||||
}
|
||||
|
||||
return !!res?.sendVerifyChangeEmail;
|
||||
},
|
||||
[pushNotification, searchParams, sendVerifyChangeEmail, t]
|
||||
[searchParams, sendVerifyChangeEmail, t]
|
||||
);
|
||||
|
||||
const onSetPassword = useCallback(
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { pushNotificationAtom } from '@affine/component/notification-center';
|
||||
import { notify } from '@affine/component';
|
||||
import {
|
||||
AffineShapeIcon,
|
||||
useEditCollection,
|
||||
@@ -17,7 +17,6 @@ import {
|
||||
ViewLayersIcon,
|
||||
} from '@blocksuite/icons';
|
||||
import { useLiveData, useService, Workspace } from '@toeverything/infra';
|
||||
import { useSetAtom } from 'jotai';
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
import { useParams } from 'react-router-dom';
|
||||
|
||||
@@ -70,7 +69,6 @@ export const Component = function CollectionPage() {
|
||||
const params = useParams();
|
||||
const workspace = useService(Workspace);
|
||||
const collection = collections.find(v => v.id === params.collectionId);
|
||||
const pushNotification = useSetAtom(pushNotificationAtom);
|
||||
useEffect(() => {
|
||||
if (!collection) {
|
||||
navigate.jumpToSubPath(workspace.id, WorkspaceSubPath.ALL);
|
||||
@@ -85,17 +83,13 @@ export const Component = function CollectionPage() {
|
||||
text = `${collection.collection.name} has been deleted`;
|
||||
}
|
||||
}
|
||||
pushNotification({
|
||||
type: 'error',
|
||||
title: text,
|
||||
});
|
||||
notify.error({ title: text });
|
||||
}
|
||||
}, [
|
||||
collection,
|
||||
collectionService.collectionsTrash$.value,
|
||||
navigate,
|
||||
params.collectionId,
|
||||
pushNotification,
|
||||
workspace.docCollection,
|
||||
workspace.id,
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user