mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-21 12:06:35 +08:00
feat: refactor trash, page would delete from its parent's subpageIds after move to trash (#1871)
This commit is contained in:
@@ -2,7 +2,7 @@ import { MenuItem } from '@affine/component';
|
||||
import { useTranslation } from '@affine/i18n';
|
||||
import { ArrowRightSmallIcon, MoveToIcon } from '@blocksuite/icons';
|
||||
import type { PageMeta } from '@blocksuite/store';
|
||||
import { useMemo, useRef, useState } from 'react';
|
||||
import { useRef, useState } from 'react';
|
||||
|
||||
import type { BlockSuiteWorkspace } from '../../../shared';
|
||||
import { PinboardMenu } from '../pinboard';
|
||||
@@ -47,10 +47,7 @@ export const MoveTo = ({
|
||||
anchorEl={anchorEl}
|
||||
open={open}
|
||||
placement="left-start"
|
||||
metas={useMemo(
|
||||
() => metas.filter(m => !m.trash && m.id !== currentMeta.id),
|
||||
[metas, currentMeta]
|
||||
)}
|
||||
metas={metas}
|
||||
currentMeta={currentMeta}
|
||||
blockSuiteWorkspace={blockSuiteWorkspace}
|
||||
onPinboardClick={onSelect}
|
||||
|
||||
@@ -3,7 +3,7 @@ import { Input, PureMenu, TreeView } from '@affine/component';
|
||||
import { useTranslation } from '@affine/i18n';
|
||||
import { RemoveIcon, SearchIcon } from '@blocksuite/icons';
|
||||
import type { PageMeta } from '@blocksuite/store';
|
||||
import React, { useCallback, useState } from 'react';
|
||||
import React, { useCallback, useMemo, useState } from 'react';
|
||||
|
||||
import { usePageMetaHelper } from '../../../../hooks/use-page-meta';
|
||||
import { usePinboardData } from '../../../../hooks/use-pinboard-data';
|
||||
@@ -29,13 +29,17 @@ export type PinboardMenuProps = {
|
||||
} & PureMenuProps;
|
||||
|
||||
export const PinboardMenu = ({
|
||||
metas,
|
||||
metas: propsMetas,
|
||||
currentMeta,
|
||||
blockSuiteWorkspace,
|
||||
showRemovePinboard = false,
|
||||
onPinboardClick,
|
||||
...pureMenuProps
|
||||
}: PinboardMenuProps) => {
|
||||
const metas = useMemo(
|
||||
() => propsMetas.filter(m => m.id !== currentMeta.id),
|
||||
[currentMeta.id, propsMetas]
|
||||
);
|
||||
const { t } = useTranslation();
|
||||
const { setPageMeta } = usePageMetaHelper(blockSuiteWorkspace);
|
||||
const [query, setQuery] = useState('');
|
||||
|
||||
@@ -10,7 +10,7 @@ import type { PageMeta } from '@blocksuite/store';
|
||||
import { useTheme } from '@mui/material';
|
||||
import { useMemo, useState } from 'react';
|
||||
|
||||
import { usePageMetaHelper } from '../../../../hooks/use-page-meta';
|
||||
import { useMetaHelper } from '../../../../hooks/affine/use-meta-helper';
|
||||
import type { BlockSuiteWorkspace } from '../../../../shared';
|
||||
import { toast } from '../../../../utils';
|
||||
import { CopyLink, MoveToTrash } from '../../operation-menu-items';
|
||||
@@ -49,7 +49,7 @@ export const OperationButton = ({
|
||||
const [pinboardMenuOpen, setPinboardMenuOpen] = useState(false);
|
||||
const [confirmModalOpen, setConfirmModalOpen] = useState(false);
|
||||
const menuIndex = useMemo(() => modalIndex + 1, [modalIndex]);
|
||||
const { setPageMeta } = usePageMetaHelper(blockSuiteWorkspace);
|
||||
const { removeToTrash } = useMetaHelper(blockSuiteWorkspace);
|
||||
|
||||
return (
|
||||
<MuiClickAwayListener
|
||||
@@ -151,10 +151,7 @@ export const OperationButton = ({
|
||||
meta={currentMeta}
|
||||
onConfirm={() => {
|
||||
toast(t('Moved to Trash'));
|
||||
setPageMeta(currentMeta.id, {
|
||||
trash: true,
|
||||
trashDate: +new Date(),
|
||||
});
|
||||
removeToTrash(currentMeta.id);
|
||||
onDelete();
|
||||
}}
|
||||
onCancel={() => {
|
||||
|
||||
Reference in New Issue
Block a user