mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-17 18:16:15 +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,6 +1,9 @@
|
||||
import { atom } from 'jotai';
|
||||
import { nanoid } from 'nanoid';
|
||||
|
||||
/**
|
||||
* @deprecated use `import type { Notification } from '@affine/component'` instead
|
||||
*/
|
||||
export type Notification = {
|
||||
key?: string;
|
||||
title: string;
|
||||
@@ -19,6 +22,9 @@ const notificationsBaseAtom = atom<Notification[]>([]);
|
||||
|
||||
const expandNotificationCenterBaseAtom = atom(false);
|
||||
const cleanupQueueAtom = atom<(() => unknown)[]>([]);
|
||||
/**
|
||||
* @deprecated use `import { notify } from '@affine/component'` instead
|
||||
*/
|
||||
export const expandNotificationCenterAtom = atom<boolean, [boolean], void>(
|
||||
get => get(expandNotificationCenterBaseAtom),
|
||||
(get, set, value) => {
|
||||
@@ -29,17 +35,24 @@ export const expandNotificationCenterAtom = atom<boolean, [boolean], void>(
|
||||
set(expandNotificationCenterBaseAtom, value);
|
||||
}
|
||||
);
|
||||
|
||||
/**
|
||||
* @deprecated use `import { notify } from '@affine/component'` instead
|
||||
*/
|
||||
export const notificationsAtom = atom<Notification[]>(get =>
|
||||
get(notificationsBaseAtom)
|
||||
);
|
||||
|
||||
/**
|
||||
* @deprecated use `import { notify } from '@affine/component'` instead
|
||||
*/
|
||||
export const removeNotificationAtom = atom(null, (_, set, key: string) => {
|
||||
set(notificationsBaseAtom, notifications =>
|
||||
notifications.filter(notification => notification.key !== key)
|
||||
);
|
||||
});
|
||||
|
||||
/**
|
||||
* @deprecated use `import { notify } from '@affine/component'` instead
|
||||
*/
|
||||
export const pushNotificationAtom = atom<null, [Notification], void>(
|
||||
null,
|
||||
(_, set, newNotification) => {
|
||||
|
||||
@@ -375,6 +375,9 @@ function NotificationCard(props: NotificationCardProps): ReactNode {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use `import { NotificationCenter } from '@affine/component'` instead
|
||||
*/
|
||||
export function NotificationCenter(): ReactNode {
|
||||
const notifications = useAtomValue(notificationsAtom);
|
||||
const [expand, setExpand] = useAtom(expandNotificationCenterAtom);
|
||||
|
||||
Reference in New Issue
Block a user