mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-17 01:56:27 +08:00
chore: migrate page method to hooks
This commit is contained in:
@@ -28,15 +28,11 @@ import { useRouter } from 'next/router';
|
||||
import { useConfirm } from '@/providers/confirm-provider';
|
||||
import { SyncIcon } from './sync-icon';
|
||||
import { toast } from '@/components/toast';
|
||||
|
||||
import useCurrentPageMeta from '@/hooks/use-current-page-meta';
|
||||
import { usePageHelper } from '@/hooks/use-page-helper';
|
||||
const PopoverContent = () => {
|
||||
const {
|
||||
getPageMeta,
|
||||
editor,
|
||||
currentPage,
|
||||
toggleFavoritePage,
|
||||
toggleDeletePage,
|
||||
} = useAppState();
|
||||
const { getPageMeta, editor, currentPage } = useAppState();
|
||||
const { toggleFavoritePage, toggleDeletePage } = usePageHelper();
|
||||
const { mode, setMode } = useEditor();
|
||||
const { confirm } = useConfirm();
|
||||
|
||||
@@ -192,7 +188,8 @@ const HeaderRight = () => {
|
||||
|
||||
export const Header = ({ children }: PropsWithChildren<{}>) => {
|
||||
const [showWarning, setShowWarning] = useState(shouldShowWarning());
|
||||
|
||||
const currentPageMeta = useCurrentPageMeta();
|
||||
console.log('currentPageMeta', currentPageMeta);
|
||||
return (
|
||||
<StyledHeaderContainer hasWarning={showWarning}>
|
||||
<BrowserWarning
|
||||
|
||||
@@ -22,13 +22,14 @@ import { Tooltip } from '@/ui/tooltip';
|
||||
import { useRouter } from 'next/router';
|
||||
import { useAppState } from '@/providers/app-state-provider/context';
|
||||
import { toast } from '@/components/toast';
|
||||
import { usePageHelper } from '@/hooks/use-page-helper';
|
||||
|
||||
const FavoriteTag = ({
|
||||
pageMeta: { favorite, id },
|
||||
}: {
|
||||
pageMeta: PageMeta;
|
||||
}) => {
|
||||
const { toggleFavoritePage } = useAppState();
|
||||
const { toggleFavoritePage } = usePageHelper();
|
||||
return (
|
||||
<Tooltip
|
||||
content={favorite ? 'Favourited' : 'Favourite'}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { useRouter } from 'next/router';
|
||||
import { PageMeta, useEditor } from '@/providers/editor-provider';
|
||||
import { useConfirm } from '@/providers/confirm-provider';
|
||||
import { useAppState } from '@/providers/app-state-provider/context';
|
||||
@@ -16,11 +15,12 @@ import {
|
||||
TrashIcon,
|
||||
} from '@blocksuite/icons';
|
||||
import { toast } from '@/components/toast';
|
||||
import { usePageHelper } from '@/hooks/use-page-helper';
|
||||
|
||||
export const OperationCell = ({ pageMeta }: { pageMeta: PageMeta }) => {
|
||||
const { id, favorite } = pageMeta;
|
||||
const goToPage = useGoToPage();
|
||||
const { toggleFavoritePage, toggleDeletePage } = useAppState();
|
||||
const { toggleFavoritePage, toggleDeletePage } = usePageHelper();
|
||||
const { confirm } = useConfirm();
|
||||
|
||||
const OperationMenu = (
|
||||
|
||||
@@ -11,6 +11,7 @@ import { usePageList } from '@/providers/app-state-provider/usePageList';
|
||||
import { useLoadWorkspace } from '@/providers/app-state-provider/hooks';
|
||||
import NextImage from 'next/image';
|
||||
import noResultImage from './jungle-searching.png';
|
||||
import { usePageHelper } from '@/hooks/use-page-helper';
|
||||
export const Results = (props: {
|
||||
query: string;
|
||||
loading: boolean;
|
||||
@@ -26,7 +27,8 @@ export const Results = (props: {
|
||||
const pageList = usePageList(workspace);
|
||||
const goToPage = useGoToPage();
|
||||
const router = useRouter();
|
||||
const { search, currentWorkspaceId } = useAppState();
|
||||
const { currentWorkspaceId } = useAppState();
|
||||
const { search } = usePageHelper();
|
||||
const List = config(currentWorkspaceId);
|
||||
const [results, setResults] = useState(new Map<string, string | undefined>());
|
||||
useEffect(() => {
|
||||
|
||||
Reference in New Issue
Block a user