mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-16 17:46:18 +08:00
feat: add toast when favorite status change
This commit is contained in:
@@ -4,7 +4,7 @@ import { Workspace } from '@blocksuite/store';
|
||||
import { useRouter } from 'next/router';
|
||||
import { EditorHandlers, PageMeta } from '../interface';
|
||||
import { EditorContainer } from '@blocksuite/editor';
|
||||
|
||||
import toast from '@/components/toast';
|
||||
export const useEditorHandler = ({
|
||||
editor,
|
||||
workspace,
|
||||
@@ -44,20 +44,17 @@ export const useEditorHandler = ({
|
||||
});
|
||||
}
|
||||
},
|
||||
favoritePage: pageId => {
|
||||
workspace!.setPageMeta(pageId, { favorite: true });
|
||||
},
|
||||
permanentlyDeletePage: pageId => {
|
||||
// TODO: workspace.meta.removePage or workspace.removePage?
|
||||
workspace!.meta.removePage(pageId);
|
||||
},
|
||||
unFavoritePage: pageId => {
|
||||
workspace!.setPageMeta(pageId, { favorite: true });
|
||||
},
|
||||
toggleFavoritePage: pageId => {
|
||||
const pageMeta = workspace?.meta.pageMetas.find(p => p.id === pageId);
|
||||
if (pageMeta) {
|
||||
workspace!.setPageMeta(pageId, { favorite: !pageMeta.favorite });
|
||||
toast(
|
||||
pageMeta.favorite ? 'Removed to Favourites' : 'Added to Favourites'
|
||||
);
|
||||
}
|
||||
},
|
||||
search: (query: QueryContent) => {
|
||||
|
||||
@@ -33,8 +33,6 @@ export type EditorHandlers = {
|
||||
) => Promise<boolean>;
|
||||
getPageMeta: (pageId: string) => PageMeta | void;
|
||||
toggleDeletePage: (pageId: string) => void;
|
||||
favoritePage: (pageId: string) => void;
|
||||
unFavoritePage: (pageId: string) => void;
|
||||
toggleFavoritePage: (pageId: string) => void;
|
||||
permanentlyDeletePage: (pageId: string) => void;
|
||||
search: (query: QueryContent) => Map<string, string | undefined>;
|
||||
|
||||
Reference in New Issue
Block a user