refactor: extract useBlockSuite from useAppState (#1001)

This commit is contained in:
Himself65
2023-02-14 21:12:35 -06:00
committed by GitHub
parent 6c0db247b7
commit 5a0e4895cd
13 changed files with 160 additions and 110 deletions
@@ -17,9 +17,9 @@ import {
import { MuiSlide } from '@affine/component';
import { Tooltip } from '@affine/component';
import useCurrentPageMeta from '@/hooks/use-current-page-meta';
import { useAppState } from '@/providers/app-state-provider';
import useHistoryUpdated from '@/hooks/use-history-update';
import { useTranslation } from '@affine/i18n';
import { useBlockSuite } from '@/store/workspace';
const useToolbarList1 = () => {
const { t } = useTranslation();
@@ -87,7 +87,7 @@ const useToolbarList1 = () => {
const UndoRedo = () => {
const [canUndo, setCanUndo] = useState(false);
const [canRedo, setCanRedo] = useState(false);
const { currentPage } = useAppState();
const currentPage = useBlockSuite(store => store.currentPage);
const onHistoryUpdated = useHistoryUpdated();
const { t } = useTranslation();
useEffect(() => {
@@ -6,17 +6,17 @@ import {
StyledTitleWrapper,
} from './styles';
import { Content } from '@affine/component';
import { useAppState } from '@/providers/app-state-provider';
import EditorModeSwitch from '@/components/editor-mode-switch';
import QuickSearchButton from './QuickSearchButton';
import Header from './Header';
import usePropsUpdated from '@/hooks/use-props-updated';
import useCurrentPageMeta from '@/hooks/use-current-page-meta';
import { useBlockSuite } from '@/store/workspace';
export const EditorHeader = () => {
const [title, setTitle] = useState('');
const [isHover, setIsHover] = useState(false);
const { editor } = useAppState();
const editor = useBlockSuite(store => store.editor);
const { trash: isTrash = false } = useCurrentPageMeta() || {};
const onPropsUpdated = usePropsUpdated();
@@ -11,14 +11,14 @@ import {
PaperIcon,
TrashIcon,
} from '@blocksuite/icons';
import { useAppState } from '@/providers/app-state-provider';
import { usePageHelper } from '@/hooks/use-page-helper';
import { useConfirm } from '@/providers/ConfirmProvider';
import useCurrentPageMeta from '@/hooks/use-current-page-meta';
import { toast } from '@affine/component';
import { useTranslation } from '@affine/i18n';
import { useBlockSuite } from '@/store/workspace';
const PopoverContent = () => {
const { editor } = useAppState();
const editor = useBlockSuite(store => store.editor);
const { toggleFavoritePage, toggleDeletePage } = usePageHelper();
const { changePageMode } = usePageHelper();
const confirm = useConfirm(store => store.confirm);
@@ -11,7 +11,7 @@ import { Tooltip } from '@affine/component';
import { useTranslation } from '@affine/i18n';
import { useModal } from '@/store/globalModal';
import { MuiFade } from '@affine/component';
import { useAppState } from '@/providers/app-state-provider';
import { useBlockSuite } from '@/store/workspace';
export type IslandItemNames = 'contact' | 'shortcuts';
export const HelpIsland = ({
showList = ['contact', 'shortcuts'],
@@ -20,7 +20,7 @@ export const HelpIsland = ({
}) => {
const [spread, setShowSpread] = useState(false);
const { triggerShortcutsModal, triggerContactModal } = useModal();
const { blockHub } = useAppState();
const blockHub = useBlockSuite(store => store.blockHub);
const { t } = useTranslation();
useEffect(() => {