mirror of
https://github.com/toeverything/AFFiNE.git
synced 2024-12-22 10:21:37 +03:00
refactor: move non-affine hooks (#1857)
This commit is contained in:
parent
d9e42d6a0f
commit
401cad799e
@ -5,9 +5,9 @@ import { RemoveIcon, SearchIcon } from '@blocksuite/icons';
|
||||
import type { PageMeta } from '@blocksuite/store';
|
||||
import React, { useCallback, useState } from 'react';
|
||||
|
||||
import { usePinboardData } from '../../../../hooks/affine/use-pinboard-data';
|
||||
import { usePinboardHandler } from '../../../../hooks/affine/use-pinboard-handler';
|
||||
import { usePageMetaHelper } from '../../../../hooks/use-page-meta';
|
||||
import { usePinboardData } from '../../../../hooks/use-pinboard-data';
|
||||
import { usePinboardHandler } from '../../../../hooks/use-pinboard-handler';
|
||||
import type { BlockSuiteWorkspace } from '../../../../shared';
|
||||
import { toast } from '../../../../utils';
|
||||
import { PinboardRender } from '../pinboard-render/';
|
||||
|
@ -10,8 +10,8 @@ import { useRouter } from 'next/router';
|
||||
import { useMemo, useState } from 'react';
|
||||
|
||||
import { workspacePreferredModeAtom } from '../../../../atoms';
|
||||
import type { PinboardNode } from '../../../../hooks/affine/use-pinboard-data';
|
||||
import { usePageMetaHelper } from '../../../../hooks/use-page-meta';
|
||||
import type { PinboardNode } from '../../../../hooks/use-pinboard-data';
|
||||
import { StyledCollapsedButton, StyledPinboard } from '../styles';
|
||||
import EmptyItem from './EmptyItem';
|
||||
import { OperationButton } from './OperationButton';
|
||||
|
@ -6,8 +6,8 @@ import {
|
||||
useGuideHidden,
|
||||
useGuideHiddenUntilNextUpdate,
|
||||
useUpdateTipsOnVersionChange,
|
||||
} from '../../../hooks/affine/use-is-first-load';
|
||||
import { useSidebarStatus } from '../../../hooks/affine/use-sidebar-status';
|
||||
} from '../../../hooks/use-is-first-load';
|
||||
import { useSidebarStatus } from '../../../hooks/use-sidebar-status';
|
||||
import { SidebarSwitchIcon } from './icons';
|
||||
import { StyledSidebarSwitch } from './style';
|
||||
type SidebarSwitchProps = {
|
||||
|
@ -7,7 +7,7 @@ import { forwardRef, useEffect, useMemo, useState } from 'react';
|
||||
import {
|
||||
useSidebarFloating,
|
||||
useSidebarStatus,
|
||||
} from '../../../hooks/affine/use-sidebar-status';
|
||||
} from '../../../hooks/use-sidebar-status';
|
||||
import { SidebarSwitch } from '../../affine/sidebar-switch';
|
||||
import { EditorOptionMenu } from './header-right-items/EditorOptionMenu';
|
||||
import SyncUser from './header-right-items/SyncUser';
|
||||
|
@ -8,7 +8,7 @@ import type { HTMLAttributes } from 'react';
|
||||
import { forwardRef, useCallback, useRef } from 'react';
|
||||
|
||||
import { currentEditorAtom, openQuickSearchModalAtom } from '../../../atoms';
|
||||
import { useGuideHidden } from '../../../hooks/affine/use-is-first-load';
|
||||
import { useGuideHidden } from '../../../hooks/use-is-first-load';
|
||||
import { usePageMeta } from '../../../hooks/use-page-meta';
|
||||
import { useElementResizeEffect } from '../../../hooks/use-workspaces';
|
||||
import type { BlockSuiteWorkspace } from '../../../shared';
|
||||
|
@ -8,9 +8,9 @@ import type { NextRouter } from 'next/router';
|
||||
import type { Dispatch, FC, SetStateAction } from 'react';
|
||||
import { useEffect } from 'react';
|
||||
|
||||
import { useRecentlyViewed } from '../../../hooks/affine/use-recent-views';
|
||||
import { useBlockSuiteWorkspaceHelper } from '../../../hooks/use-blocksuite-workspace-helper';
|
||||
import { usePageMeta } from '../../../hooks/use-page-meta';
|
||||
import { useRecentlyViewed } from '../../../hooks/use-recent-views';
|
||||
import { useRouterHelper } from '../../../hooks/use-router-helper';
|
||||
import type { BlockSuiteWorkspace } from '../../../shared';
|
||||
import { useSwitchToConfig } from './config';
|
||||
|
@ -3,9 +3,9 @@ import type { PageMeta } from '@blocksuite/store';
|
||||
import type { MouseEvent } from 'react';
|
||||
import { useCallback } from 'react';
|
||||
|
||||
import type { PinboardNode } from '../../../hooks/affine/use-pinboard-data';
|
||||
import { usePinboardData } from '../../../hooks/affine/use-pinboard-data';
|
||||
import { usePinboardHandler } from '../../../hooks/affine/use-pinboard-handler';
|
||||
import type { PinboardNode } from '../../../hooks/use-pinboard-data';
|
||||
import { usePinboardData } from '../../../hooks/use-pinboard-data';
|
||||
import { usePinboardHandler } from '../../../hooks/use-pinboard-handler';
|
||||
import type { BlockSuiteWorkspace } from '../../../shared';
|
||||
import { PinboardRender } from '../../affine/pinboard';
|
||||
|
||||
|
@ -6,7 +6,7 @@ import { useCallback, useState } from 'react';
|
||||
import {
|
||||
useGuideHidden,
|
||||
useGuideHiddenUntilNextUpdate,
|
||||
} from '../../../../hooks/affine/use-is-first-load';
|
||||
} from '../../../../hooks/use-is-first-load';
|
||||
import { StyledChangeLog, StyledChangeLogWrapper } from '../shared-styles';
|
||||
import { StyledLink } from '../style';
|
||||
|
||||
|
@ -11,13 +11,13 @@ import type { Page, PageMeta } from '@blocksuite/store';
|
||||
import type React from 'react';
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
|
||||
import { usePageMeta } from '../../../hooks/use-page-meta';
|
||||
import {
|
||||
useSidebarFloating,
|
||||
useSidebarResizing,
|
||||
useSidebarStatus,
|
||||
useSidebarWidth,
|
||||
} from '../../../hooks/affine/use-sidebar-status';
|
||||
import { usePageMeta } from '../../../hooks/use-page-meta';
|
||||
} from '../../../hooks/use-sidebar-status';
|
||||
import type { AllWorkspace } from '../../../shared';
|
||||
import { SidebarSwitch } from '../../affine/sidebar-switch';
|
||||
import { ChangeLog } from './changeLog';
|
||||
|
@ -23,21 +23,21 @@ import { beforeAll, beforeEach, describe, expect, test, vi } from 'vitest';
|
||||
import { currentWorkspaceIdAtom, workspacesAtom } from '../../atoms';
|
||||
import { LocalPlugin } from '../../plugins/local';
|
||||
import { BlockSuiteWorkspace, WorkspaceSubPath } from '../../shared';
|
||||
import {
|
||||
currentWorkspaceAtom,
|
||||
useCurrentWorkspace,
|
||||
} from '../current/use-current-workspace';
|
||||
import {
|
||||
useGuideHidden,
|
||||
useGuideHiddenUntilNextUpdate,
|
||||
useLastVersion,
|
||||
useTipsDisplayStatus,
|
||||
} from '../affine/use-is-first-load';
|
||||
} from '../use-is-first-load';
|
||||
import { usePageMeta, usePageMetaHelper } from '../use-page-meta';
|
||||
import {
|
||||
useRecentlyViewed,
|
||||
useSyncRecentViewsWithRouter,
|
||||
} from '../affine/use-recent-views';
|
||||
import {
|
||||
currentWorkspaceAtom,
|
||||
useCurrentWorkspace,
|
||||
} from '../current/use-current-workspace';
|
||||
import { usePageMeta, usePageMetaHelper } from '../use-page-meta';
|
||||
} from '../use-recent-views';
|
||||
import {
|
||||
REDIRECT_TIMEOUT,
|
||||
useSyncRouterWithCurrentWorkspaceAndPage,
|
||||
|
6
apps/web/src/hooks/affine/README.md
Normal file
6
apps/web/src/hooks/affine/README.md
Normal file
@ -0,0 +1,6 @@
|
||||
# AFFiNE Hooks
|
||||
|
||||
> This directory will be moved to `@affine/worksapce/affine/hooks` in the future.
|
||||
|
||||
Only put hooks in this directory if they are specific to AFFiNE, for example
|
||||
if they are using the AFFiNE API, or if the `AffineWorkspace` is required.
|
@ -6,7 +6,7 @@ import {
|
||||
guideHiddenAtom,
|
||||
guideHiddenUntilNextUpdateAtom,
|
||||
lastVersionAtom,
|
||||
} from '../../atoms/first-load';
|
||||
} from '../atoms/first-load';
|
||||
|
||||
export function useLastVersion() {
|
||||
return useAtom(lastVersionAtom);
|
@ -3,7 +3,7 @@ import type { PageMeta } from '@blocksuite/store';
|
||||
import type { MouseEvent } from 'react';
|
||||
import { useMemo } from 'react';
|
||||
|
||||
import type { BlockSuiteWorkspace } from '../../shared';
|
||||
import type { BlockSuiteWorkspace } from '../shared';
|
||||
|
||||
export type RenderProps = {
|
||||
blockSuiteWorkspace: BlockSuiteWorkspace;
|
@ -4,9 +4,9 @@ import type { PageMeta } from '@blocksuite/store';
|
||||
import { nanoid } from '@blocksuite/store';
|
||||
import { useCallback } from 'react';
|
||||
|
||||
import type { BlockSuiteWorkspace } from '../../shared';
|
||||
import { useBlockSuiteWorkspaceHelper } from '../use-blocksuite-workspace-helper';
|
||||
import { usePageMetaHelper } from '../use-page-meta';
|
||||
import type { BlockSuiteWorkspace } from '../shared';
|
||||
import { useBlockSuiteWorkspaceHelper } from './use-blocksuite-workspace-helper';
|
||||
import { usePageMetaHelper } from './use-page-meta';
|
||||
import type { NodeRenderProps, PinboardNode } from './use-pinboard-data';
|
||||
|
||||
const logger = new DebugLogger('pinboard');
|
@ -6,9 +6,9 @@ import {
|
||||
workspacePreferredModeAtom,
|
||||
workspaceRecentViewsAtom,
|
||||
workspaceRecentViresWriteAtom,
|
||||
} from '../../atoms';
|
||||
import { useCurrentWorkspace } from '../current/use-current-workspace';
|
||||
import { usePageMeta } from '../use-page-meta';
|
||||
} from '../atoms';
|
||||
import { useCurrentWorkspace } from './current/use-current-workspace';
|
||||
import { usePageMeta } from './use-page-meta';
|
||||
|
||||
export function useRecentlyViewed() {
|
||||
const [workspace] = useCurrentWorkspace();
|
@ -25,18 +25,18 @@ import {
|
||||
import { HelpIsland } from '../components/pure/help-island';
|
||||
import { PageLoading } from '../components/pure/loading';
|
||||
import WorkSpaceSliderBar from '../components/pure/workspace-slider-bar';
|
||||
import {
|
||||
useSidebarFloating,
|
||||
useSidebarResizing,
|
||||
useSidebarStatus,
|
||||
useSidebarWidth,
|
||||
} from '../hooks/affine/use-sidebar-status';
|
||||
import { useCurrentPageId } from '../hooks/current/use-current-page-id';
|
||||
import { useCurrentWorkspace } from '../hooks/current/use-current-workspace';
|
||||
import { useBlockSuiteWorkspaceHelper } from '../hooks/use-blocksuite-workspace-helper';
|
||||
import { useCreateFirstWorkspace } from '../hooks/use-create-first-workspace';
|
||||
import { useRouterHelper } from '../hooks/use-router-helper';
|
||||
import { useRouterTitle } from '../hooks/use-router-title';
|
||||
import {
|
||||
useSidebarFloating,
|
||||
useSidebarResizing,
|
||||
useSidebarStatus,
|
||||
useSidebarWidth,
|
||||
} from '../hooks/use-sidebar-status';
|
||||
import { useWorkspaces } from '../hooks/use-workspaces';
|
||||
import { WorkspacePlugins } from '../plugins';
|
||||
import { ModalProvider } from '../providers/ModalProvider';
|
||||
|
@ -5,9 +5,9 @@ import { useEffect } from 'react';
|
||||
|
||||
import { Unreachable } from '../../../components/affine/affine-error-eoundary';
|
||||
import { PageLoading } from '../../../components/pure/loading';
|
||||
import { useSyncRecentViewsWithRouter } from '../../../hooks/affine/use-recent-views';
|
||||
import { useCurrentPageId } from '../../../hooks/current/use-current-page-id';
|
||||
import { useCurrentWorkspace } from '../../../hooks/current/use-current-workspace';
|
||||
import { useSyncRecentViewsWithRouter } from '../../../hooks/use-recent-views';
|
||||
import { useSyncRouterWithCurrentWorkspaceAndPage } from '../../../hooks/use-sync-router-with-current-workspace-and-page';
|
||||
import { WorkspaceLayout } from '../../../layouts';
|
||||
import { WorkspacePlugins } from '../../../plugins';
|
||||
|
Loading…
Reference in New Issue
Block a user