From 926bb7fd14dfdbbb5918b097351a6d064252be65 Mon Sep 17 00:00:00 2001 From: QiShaoXuan Date: Wed, 11 Jan 2023 16:33:25 +0800 Subject: [PATCH 1/3] chore: remove currentWorkspaceId & currentMetaWorkspace --- .../header-right-items/TrashButtonGroup.tsx | 4 +-- .../app/src/components/page-list/index.tsx | 4 +-- .../app/src/components/quick-search/Input.tsx | 8 ++--- .../src/components/quick-search/Results.tsx | 4 +-- .../app/src/components/quick-search/config.ts | 8 ++--- .../app/src/components/quick-search/index.tsx | 6 ++-- .../workspace-setting/MembersPage.tsx | 2 -- .../workspace-setting/general/General.tsx | 1 - .../WorkspaceSelector/WorkspaceSelector.tsx | 10 +++--- .../components/workspace-slider-bar/index.tsx | 4 +-- packages/app/src/hooks/use-init-workspace.ts | 34 ------------------- packages/app/src/hooks/use-page-helper.ts | 6 ++-- .../app/src/hooks/use-workspace-helper.ts | 7 ++-- .../pages/workspace/[workspaceId]/index.tsx | 3 +- .../pages/workspace/[workspaceId]/setting.tsx | 4 +-- packages/app/src/pages/workspace/index.tsx | 6 ++-- .../providers/app-state-provider/Provider.tsx | 16 ++------- .../providers/app-state-provider/interface.ts | 2 -- pnpm-lock.yaml | 24 ------------- 19 files changed, 37 insertions(+), 116 deletions(-) delete mode 100644 packages/app/src/hooks/use-init-workspace.ts diff --git a/packages/app/src/components/header/header-right-items/TrashButtonGroup.tsx b/packages/app/src/components/header/header-right-items/TrashButtonGroup.tsx index 615648e975..af0a12a8d4 100644 --- a/packages/app/src/components/header/header-right-items/TrashButtonGroup.tsx +++ b/packages/app/src/components/header/header-right-items/TrashButtonGroup.tsx @@ -8,7 +8,7 @@ import { useTranslation } from '@affine/i18n'; export const TrashButtonGroup = () => { const { permanentlyDeletePage } = usePageHelper(); - const { currentWorkspaceId } = useAppState(); + const { currentWorkspace } = useAppState(); const { toggleDeletePage } = usePageHelper(); const { confirm } = useConfirm(); const router = useRouter(); @@ -38,7 +38,7 @@ export const TrashButtonGroup = () => { confirmType: 'danger', }).then(confirm => { if (confirm) { - router.push(`/workspace/${currentWorkspaceId}/all`); + router.push(`/workspace/${currentWorkspace?.id}/all`); permanentlyDeletePage(id); } }); diff --git a/packages/app/src/components/page-list/index.tsx b/packages/app/src/components/page-list/index.tsx index d31767b818..6ae13b071d 100644 --- a/packages/app/src/components/page-list/index.tsx +++ b/packages/app/src/components/page-list/index.tsx @@ -73,7 +73,7 @@ export const PageList = ({ isTrash?: boolean; }) => { const router = useRouter(); - const { currentWorkspaceId } = useAppState(); + const { currentWorkspace } = useAppState(); const { t } = useTranslation(); if (pageList.length === 0) { return ; @@ -99,7 +99,7 @@ export const PageList = ({ key={`${pageMeta.id}-${index}`} onClick={() => { router.push( - `/workspace/${currentWorkspaceId}/${pageMeta.id}` + `/workspace/${currentWorkspace?.id}/${pageMeta.id}` ); }} > diff --git a/packages/app/src/components/quick-search/Input.tsx b/packages/app/src/components/quick-search/Input.tsx index 6b5a6395d5..83ff131f71 100644 --- a/packages/app/src/components/quick-search/Input.tsx +++ b/packages/app/src/components/quick-search/Input.tsx @@ -17,10 +17,8 @@ export const Input = (props: { const [isComposition, setIsComposition] = useState(false); const [inputValue, setInputValue] = useState(''); const inputRef = useRef(null); - const { currentWorkspaceId, workspaceList, currentWorkspace } = useAppState(); - const isPublish = workspaceList.find( - meta => String(meta.id) === String(currentWorkspaceId) - )?.published; + const { currentWorkspace } = useAppState(); + useEffect(() => { inputRef.current?.addEventListener( 'blur', @@ -79,7 +77,7 @@ export const Input = (props: { } }} placeholder={ - isPublish + currentWorkspace?.isPublish ? `Search in ${currentWorkspace?.blocksuiteWorkspace?.meta.name}` : 'Quick Search...' } diff --git a/packages/app/src/components/quick-search/Results.tsx b/packages/app/src/components/quick-search/Results.tsx index c0949ae803..fe9cc5d883 100644 --- a/packages/app/src/components/quick-search/Results.tsx +++ b/packages/app/src/components/quick-search/Results.tsx @@ -22,9 +22,9 @@ export const Results = (props: { const { triggerQuickSearchModal } = useModal(); const { openPage } = usePageHelper(); const router = useRouter(); - const { currentWorkspaceId, pageList } = useAppState(); + const { currentWorkspace, pageList } = useAppState(); const { search } = usePageHelper(); - const List = useSwitchToConfig(currentWorkspaceId); + const List = useSwitchToConfig(currentWorkspace?.id); const [results, setResults] = useState(new Map()); const { t } = useTranslation(); useEffect(() => { diff --git a/packages/app/src/components/quick-search/config.ts b/packages/app/src/components/quick-search/config.ts index ce99ad5627..4738e93554 100644 --- a/packages/app/src/components/quick-search/config.ts +++ b/packages/app/src/components/quick-search/config.ts @@ -1,15 +1,16 @@ +import { FC, SVGProps } from 'react'; import { AllPagesIcon, FavouritesIcon, TrashIcon } from '@blocksuite/icons'; import { useTranslation } from '@affine/i18n'; export const useSwitchToConfig = ( - currentWorkspaceId: string + currentWorkspaceId?: string ): { title: string; href: string; - icon: React.FC>; + icon: FC>; }[] => { const { t } = useTranslation(); - const List = [ + return [ { title: t('All pages'), href: currentWorkspaceId ? `/workspace/${currentWorkspaceId}/all` : '', @@ -28,5 +29,4 @@ export const useSwitchToConfig = ( icon: TrashIcon, }, ]; - return List; }; diff --git a/packages/app/src/components/quick-search/index.tsx b/packages/app/src/components/quick-search/index.tsx index 1450531f5a..4000ce7756 100644 --- a/packages/app/src/components/quick-search/index.tsx +++ b/packages/app/src/components/quick-search/index.tsx @@ -22,15 +22,13 @@ const isMac = () => { return getUaHelper().isMacOs; }; export const QuickSearch = ({ open, onClose }: TransitionsModalProps) => { - const { currentMetaWorkSpace } = useAppState(); + const { currentWorkspace } = useAppState(); const [query, setQuery] = useState(''); const [loading, setLoading] = useState(true); const [showCreatePage, setShowCreatePage] = useState(true); const { triggerQuickSearchModal } = useModal(); - const isPublish = currentMetaWorkSpace?.published; - // Add ‘⌘+K’ shortcut keys as switches useEffect(() => { const down = (e: KeyboardEvent) => { @@ -96,7 +94,7 @@ export const QuickSearch = ({ open, onClose }: TransitionsModalProps) => { setShowCreatePage={setShowCreatePage} /> - {isPublish ? ( + {currentWorkspace?.isPublish ? ( <> ) : showCreatePage ? ( <> diff --git a/packages/app/src/components/workspace-setting/MembersPage.tsx b/packages/app/src/components/workspace-setting/MembersPage.tsx index 937a8db576..e2a9beeae0 100644 --- a/packages/app/src/components/workspace-setting/MembersPage.tsx +++ b/packages/app/src/components/workspace-setting/MembersPage.tsx @@ -34,8 +34,6 @@ import { useConfirm } from '@/providers/ConfirmProvider'; export const MembersPage = ({ workspace }: { workspace: WorkspaceUnit }) => { const [isInviteModalShow, setIsInviteModalShow] = useState(false); - // const { currentMetaWorkSpace, currentWorkspace, dataCenter } = useAppState(); - const [members, setMembers] = useState<[{ name: string; email: string }?]>( [] ); diff --git a/packages/app/src/components/workspace-setting/general/General.tsx b/packages/app/src/components/workspace-setting/general/General.tsx index 0b01941475..65e87496d0 100644 --- a/packages/app/src/components/workspace-setting/general/General.tsx +++ b/packages/app/src/components/workspace-setting/general/General.tsx @@ -41,7 +41,6 @@ export const GeneralPage = ({ workspace }: { workspace: WorkspaceUnit }) => { setShowLeave(false); }; const handleUpdateWorkspaceName = () => { - console.log('currentWorkspace: ', currentWorkspace); currentWorkspace && updateWorkspace({ name: workspaceName }, currentWorkspace); }; diff --git a/packages/app/src/components/workspace-slider-bar/WorkspaceSelector/WorkspaceSelector.tsx b/packages/app/src/components/workspace-slider-bar/WorkspaceSelector/WorkspaceSelector.tsx index 2a19bd7d90..5997106ee3 100644 --- a/packages/app/src/components/workspace-slider-bar/WorkspaceSelector/WorkspaceSelector.tsx +++ b/packages/app/src/components/workspace-slider-bar/WorkspaceSelector/WorkspaceSelector.tsx @@ -5,7 +5,7 @@ import { WorkspaceAvatar } from '@/components/workspace-avatar'; import { useAppState } from '@/providers/app-state-provider'; export const WorkspaceSelector = () => { const [workspaceListShow, setWorkspaceListShow] = useState(false); - const { currentMetaWorkSpace, workspaceList } = useAppState(); + const { currentWorkspace, workspaceList } = useAppState(); useEffect(() => { if (workspaceList.length === 0) { @@ -23,7 +23,7 @@ export const WorkspaceSelector = () => {
{ >
- {currentMetaWorkSpace?.name ?? 'AFFiNE'} + {currentWorkspace?.name ?? 'AFFiNE'} { export const WorkSpaceSliderBar = () => { const { triggerQuickSearchModal, triggerImportModal } = useModal(); const [showSubFavorite, setShowSubFavorite] = useState(true); - const { currentWorkspaceId } = useAppState(); + const { currentWorkspace } = useAppState(); const { openPage, createPage } = usePageHelper(); const router = useRouter(); const { t } = useTranslation(); const [showTip, setShowTip] = useState(false); const [show, setShow] = useLocalStorage('AFFiNE_SLIDE_BAR', false, true); - + const currentWorkspaceId = currentWorkspace?.id; const paths = { all: currentWorkspaceId ? `/workspace/${currentWorkspaceId}/all` : '', favorite: currentWorkspaceId diff --git a/packages/app/src/hooks/use-init-workspace.ts b/packages/app/src/hooks/use-init-workspace.ts deleted file mode 100644 index 4f916365c2..0000000000 --- a/packages/app/src/hooks/use-init-workspace.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { useRouter } from 'next/router'; -import { useAppState } from '@/providers/app-state-provider'; -import { useEffect, useRef, useState } from 'react'; - -export const useInitWorkspace = (disabled?: boolean) => { - const [loading, setLoading] = useState(true); - // Do not set as a constant, or it will trigger a hell of re-rendering - const defaultOutLineWorkspaceId = useRef(new Date().getTime().toString()); - - const router = useRouter(); - const { workspaceList, loadWorkspace, currentWorkspace, currentWorkspaceId } = - useAppState(); - const workspaceId = - (router.query.workspaceId as string) || - workspaceList?.[0]?.id || - defaultOutLineWorkspaceId.current; - - useEffect(() => { - if (disabled) { - setLoading(false); - return; - } - setLoading(true); - loadWorkspace(workspaceId).finally(() => { - setLoading(false); - }); - }, [workspaceId, disabled, loadWorkspace]); - - return { - workspaceId, - workspace: workspaceId === currentWorkspaceId ? currentWorkspace : null, - loading, - }; -}; diff --git a/packages/app/src/hooks/use-page-helper.ts b/packages/app/src/hooks/use-page-helper.ts index 6b0258d73e..00133b03e4 100644 --- a/packages/app/src/hooks/use-page-helper.ts +++ b/packages/app/src/hooks/use-page-helper.ts @@ -36,7 +36,7 @@ const getPageMeta = (workspace: WorkspaceUnit | null, pageId: string) => { export const usePageHelper = (): EditorHandlers => { const router = useRouter(); const changePageMeta = useChangePageMeta(); - const { currentWorkspace, editor, currentWorkspaceId } = useAppState(); + const { currentWorkspace, editor } = useAppState(); return { createPage: ({ @@ -109,11 +109,11 @@ export const usePageHelper = (): EditorHandlers => { pageId = pageId.replace('space:', ''); if (newTab) { - window.open(`/workspace/${currentWorkspaceId}/${pageId}`, '_blank'); + window.open(`/workspace/${currentWorkspace?.id}/${pageId}`, '_blank'); return Promise.resolve(true); } return router.push({ - pathname: `/workspace/${currentWorkspaceId}/${pageId}`, + pathname: `/workspace/${currentWorkspace?.id}/${pageId}`, query, }); }, diff --git a/packages/app/src/hooks/use-workspace-helper.ts b/packages/app/src/hooks/use-workspace-helper.ts index f0e4d1f7cf..f67a3b152f 100644 --- a/packages/app/src/hooks/use-workspace-helper.ts +++ b/packages/app/src/hooks/use-workspace-helper.ts @@ -6,8 +6,7 @@ import router from 'next/router'; export const useWorkspaceHelper = () => { const { confirm } = useConfirm(); - const { dataCenter, currentWorkspace, user, login, currentMetaWorkSpace } = - useAppState(); + const { dataCenter, currentWorkspace, user, login } = useAppState(); const createWorkspace = async (name: string) => { const workspaceInfo = await dataCenter.createWorkspace({ name: name, @@ -58,8 +57,8 @@ export const useWorkspaceHelper = () => { }; const inviteMember = async (email: string) => { - currentMetaWorkSpace && - (await dataCenter.inviteMember(currentMetaWorkSpace?.id, email)); + currentWorkspace && + (await dataCenter.inviteMember(currentWorkspace?.id, email)); }; return { diff --git a/packages/app/src/pages/workspace/[workspaceId]/index.tsx b/packages/app/src/pages/workspace/[workspaceId]/index.tsx index 6ed36718b1..f946e29267 100644 --- a/packages/app/src/pages/workspace/[workspaceId]/index.tsx +++ b/packages/app/src/pages/workspace/[workspaceId]/index.tsx @@ -7,7 +7,7 @@ import usePageHelper from '@/hooks/use-page-helper'; const WorkspaceIndex = () => { const router = useRouter(); - const { currentWorkspaceId, currentWorkspace } = useAppState(); + const { currentWorkspace } = useAppState(); const { createPage } = usePageHelper(); const { workspaceLoaded, activeWorkspaceId } = useEnsureWorkspace(); @@ -29,7 +29,6 @@ const WorkspaceIndex = () => { initPage(); }, [ currentWorkspace, - currentWorkspaceId, createPage, router, workspaceLoaded, diff --git a/packages/app/src/pages/workspace/[workspaceId]/setting.tsx b/packages/app/src/pages/workspace/[workspaceId]/setting.tsx index 5d3f190207..e8c40aacf2 100644 --- a/packages/app/src/pages/workspace/[workspaceId]/setting.tsx +++ b/packages/app/src/pages/workspace/[workspaceId]/setting.tsx @@ -60,7 +60,7 @@ const tabMap: { ]; const WorkspaceSetting = () => { - const { currentMetaWorkSpace } = useAppState(); + const { currentWorkspace } = useAppState(); const [activeTab, setActiveTab] = useState(tabMap[0].name); const handleTabChange = (tab: TabNames) => { @@ -98,7 +98,7 @@ const WorkspaceSetting = () => { - {currentMetaWorkSpace && activeTabPanelRender?.(currentMetaWorkSpace)} + {currentWorkspace && activeTabPanelRender?.(currentWorkspace)} ); diff --git a/packages/app/src/pages/workspace/index.tsx b/packages/app/src/pages/workspace/index.tsx index 1fe3ba2c17..ec96879e5a 100644 --- a/packages/app/src/pages/workspace/index.tsx +++ b/packages/app/src/pages/workspace/index.tsx @@ -6,14 +6,14 @@ import { PageLoading } from '@/components/loading'; export const WorkspaceIndex = () => { const router = useRouter(); - const { currentWorkspaceId } = useAppState(); + const { currentWorkspace } = useAppState(); const { workspaceLoaded } = useEnsureWorkspace(); useEffect(() => { if (workspaceLoaded) { - router.push(`/workspace/${currentWorkspaceId}`); + router.push(`/workspace/${currentWorkspace?.id}`); } - }, [currentWorkspaceId, router, workspaceLoaded]); + }, [currentWorkspace, router, workspaceLoaded]); return ; }; diff --git a/packages/app/src/providers/app-state-provider/Provider.tsx b/packages/app/src/providers/app-state-provider/Provider.tsx index fbe04c7fe6..ef7169206e 100644 --- a/packages/app/src/providers/app-state-provider/Provider.tsx +++ b/packages/app/src/providers/app-state-provider/Provider.tsx @@ -8,7 +8,7 @@ import { PageMeta, } from './interface'; import { createDefaultWorkspace } from './utils'; -import { WorkspaceUnit, User } from '@affine/datacenter'; +import { User } from '@affine/datacenter'; type AppStateContextProps = PropsWithChildren>; @@ -34,13 +34,11 @@ export const AppStateProvider = ({ dataCenter, user: (await dataCenter.getUserInfo()) || null, workspaceList: dataCenter.workspaces, - currentWorkspaceId: '', currentWorkspace: null, pageList: [], currentPage: null, editor: null, synced: true, - currentMetaWorkSpace: null, }); }; @@ -95,27 +93,19 @@ export const AppStateProvider = ({ const loadWorkspace = useRef(); loadWorkspace.current = async (workspaceId: string) => { - const { dataCenter, workspaceList, currentWorkspaceId, currentWorkspace } = - appState; + const { dataCenter, workspaceList, currentWorkspace } = appState; if (!workspaceList.find(v => v.id.toString() === workspaceId)) { return null; } - if (workspaceId === currentWorkspaceId) { + if (workspaceId === currentWorkspace?.id) { return currentWorkspace; } const workspace = await dataCenter.loadWorkspace(workspaceId); - const currentMetaWorkSpace = dataCenter.workspaces.find( - (item: WorkspaceUnit) => { - return item.id.toString() === workspace.id; - } - ); const pageList = (workspace?.blocksuiteWorkspace?.meta.pageMetas as PageMeta[]) ?? []; setAppState({ ...appState, currentWorkspace: workspace, - currentWorkspaceId: workspaceId, - currentMetaWorkSpace: currentMetaWorkSpace ?? null, pageList: pageList, currentPage: null, editor: null, diff --git a/packages/app/src/providers/app-state-provider/interface.ts b/packages/app/src/providers/app-state-provider/interface.ts index e940927edc..6cb5f5551c 100644 --- a/packages/app/src/providers/app-state-provider/interface.ts +++ b/packages/app/src/providers/app-state-provider/interface.ts @@ -19,8 +19,6 @@ export type AppStateValue = { user: User | null; workspaceList: WorkspaceUnit[]; currentWorkspace: WorkspaceUnit | null; - currentMetaWorkSpace: WorkspaceUnit | null; - currentWorkspaceId: string; pageList: PageMeta[]; currentPage: StorePage | null; editor?: EditorContainer | null; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 83bffe31cd..16878e31f0 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -2967,7 +2967,6 @@ packages: /@next/env/13.1.0: resolution: {integrity: sha512-6iNixFzCndH+Bl4FetQzOMjxCJqg8fs0LAlZviig1K6mIjOWH2m2oPcHcOg1Ta5VCe7Bx5KG1Hs+NrWDUkBt9A==} - dev: false /@next/eslint-plugin-next/12.3.1: resolution: {integrity: sha512-sw+lTf6r6P0j+g/n9y4qdWWI2syPqZx+uc0+B/fRENqfR3KpSid6MIKqc9gNwGhJASazEQ5b3w8h4cAET213jw==} @@ -2990,7 +2989,6 @@ packages: cpu: [arm] os: [android] requiresBuild: true - dev: false optional: true /@next/swc-android-arm64/12.3.1: @@ -3008,7 +3006,6 @@ packages: cpu: [arm64] os: [android] requiresBuild: true - dev: false optional: true /@next/swc-darwin-arm64/12.3.1: @@ -3026,7 +3023,6 @@ packages: cpu: [arm64] os: [darwin] requiresBuild: true - dev: false optional: true /@next/swc-darwin-x64/12.3.1: @@ -3044,7 +3040,6 @@ packages: cpu: [x64] os: [darwin] requiresBuild: true - dev: false optional: true /@next/swc-freebsd-x64/12.3.1: @@ -3062,7 +3057,6 @@ packages: cpu: [x64] os: [freebsd] requiresBuild: true - dev: false optional: true /@next/swc-linux-arm-gnueabihf/12.3.1: @@ -3080,7 +3074,6 @@ packages: cpu: [arm] os: [linux] requiresBuild: true - dev: false optional: true /@next/swc-linux-arm64-gnu/12.3.1: @@ -3098,7 +3091,6 @@ packages: cpu: [arm64] os: [linux] requiresBuild: true - dev: false optional: true /@next/swc-linux-arm64-musl/12.3.1: @@ -3116,7 +3108,6 @@ packages: cpu: [arm64] os: [linux] requiresBuild: true - dev: false optional: true /@next/swc-linux-x64-gnu/12.3.1: @@ -3134,7 +3125,6 @@ packages: cpu: [x64] os: [linux] requiresBuild: true - dev: false optional: true /@next/swc-linux-x64-musl/12.3.1: @@ -3152,7 +3142,6 @@ packages: cpu: [x64] os: [linux] requiresBuild: true - dev: false optional: true /@next/swc-win32-arm64-msvc/12.3.1: @@ -3170,7 +3159,6 @@ packages: cpu: [arm64] os: [win32] requiresBuild: true - dev: false optional: true /@next/swc-win32-ia32-msvc/12.3.1: @@ -3188,7 +3176,6 @@ packages: cpu: [ia32] os: [win32] requiresBuild: true - dev: false optional: true /@next/swc-win32-x64-msvc/12.3.1: @@ -3206,7 +3193,6 @@ packages: cpu: [x64] os: [win32] requiresBuild: true - dev: false optional: true /@nodelib/fs.scandir/2.1.5: @@ -3569,7 +3555,6 @@ packages: resolution: {integrity: sha512-4C7nX/dvpzB7za4Ql9K81xK3HPxCpHMgwTZVyf+9JQ6VUbn9jjZVN7/Nkdz/Ugzs2CSjqnL/UPXroiVBVHUWUw==} dependencies: tslib: 2.4.0 - dev: false /@szmarczak/http-timer/5.0.1: resolution: {integrity: sha512-+PmQX0PiAYPMeVYe237LJAYvOMYW1j2rH5YROyS3b4CTVJum34HfRvKvAzozHAQG0TnHNdUfY9nCeUyRAs//cw==} @@ -4536,7 +4521,6 @@ packages: /client-only/0.0.1: resolution: {integrity: sha512-IV3Ou0jSMzZrd3pZ48nLkT9DA7Ag1pnPzaiQhpW7c3RbcqqzvzzVu+L8gfqMp/8IM2MQtSiqaCxrrcfu8I8rMA==} - dev: false /cliui/6.0.0: resolution: {integrity: sha512-t6wbgtoCXvAzst7QgXxJYqPt0usEfbgQdftEPbLL/cvv6HPE5VgvqCuAIDR0NgU52ds6rFwqrgakNLrHEjCbrQ==} @@ -7468,7 +7452,6 @@ packages: resolution: {integrity: sha512-MqBkQh/OHTS2egovRtLk45wEyNXwF+cokD+1YPf9u5VfJiRdAiRwB2froX5Co9Rh20xs4siNPm8naNotSD6RBw==} engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} hasBin: true - dev: false /natural-compare-lite/1.4.0: resolution: {integrity: sha512-Tj+HTDSJJKaZnfiuw+iaF9skdPpTo2GtEly5JHnWV/hfv2Qj/9RKsGISQtLh2ox3l5EAGw487hnBee0sIJ6v2g==} @@ -7591,7 +7574,6 @@ packages: transitivePeerDependencies: - '@babel/core' - babel-plugin-macros - dev: false /node-domexception/1.0.0: resolution: {integrity: sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==} @@ -7942,7 +7924,6 @@ packages: nanoid: 3.3.4 picocolors: 1.0.0 source-map-js: 1.0.2 - dev: false /preferred-pm/3.0.3: resolution: {integrity: sha512-+wZgbxNES/KlJs9q40F/1sfOd/j7f1O9JaHcW5Dsn3aUUOZg3L2bjpVUcKV2jvtElYfoTuQiNeMfQJ4kwUAhCQ==} @@ -8112,7 +8093,6 @@ packages: loose-envify: 1.4.0 react: 18.2.0 scheduler: 0.23.0 - dev: false /react-i18next/11.18.6_i18next@21.10.0: resolution: {integrity: sha512-yHb2F9BiT0lqoQDt8loZ5gWP331GwctHz9tYQ8A2EIEUu+CcEdjBLQWli1USG3RdWQt3W+jqQLg/d4rrQR96LA==} @@ -8209,7 +8189,6 @@ packages: engines: {node: '>=0.10.0'} dependencies: loose-envify: 1.4.0 - dev: false /read-pkg-up/7.0.1: resolution: {integrity: sha512-zK0TB7Xd6JpCLmlLmufqykGE+/TlOePD6qKClNW7hHDKFh/J7/7gCWGR7joEQEW1bKq3a3yUZSObOoWLFQ4ohg==} @@ -8487,7 +8466,6 @@ packages: resolution: {integrity: sha512-CtuThmgHNg7zIZWAXi3AsyIzA3n4xx7aNyjwC2VJldO2LMVDhFK+63xGqq6CsJH4rTAt6/M+N4GhZiDYPx9eUw==} dependencies: loose-envify: 1.4.0 - dev: false /schema-utils/2.7.1: resolution: {integrity: sha512-SHiNtMOUGWBQJwzISiVYKu82GiV4QYGePp3odlY1tuKO7gPtphAT5R/py0fA6xtbgLL/RvtJZnU9b8s0F1q0Xg==} @@ -8646,7 +8624,6 @@ packages: /source-map-js/1.0.2: resolution: {integrity: sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==} engines: {node: '>=0.10.0'} - dev: false /source-map-support/0.5.13: resolution: {integrity: sha512-SHSKFHadjVA5oR4PPqhtAVdcBWwRYVd6g6cAXnIbRiIwc2EhPrTuKUBdSLvlEKyIP3GCf89fltvcZiP9MMFA1w==} @@ -8895,7 +8872,6 @@ packages: dependencies: client-only: 0.0.1 react: 18.2.0 - dev: false /stylis/4.0.13: resolution: {integrity: sha512-xGPXiFVl4YED9Jh7Euv2V220mriG9u4B2TA6Ybjc1catrstKD2PpIdU3U0RKpkVBC2EhmL/F0sPCr9vrFTNRag==} From b6b1ae0224f917e8ab1eef0f38dd11d819e940a0 Mon Sep 17 00:00:00 2001 From: QiShaoXuan Date: Wed, 11 Jan 2023 15:12:18 +0800 Subject: [PATCH 2/3] feat: add interaction to search button --- .../components/header/QuickSearchButton.tsx | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/packages/app/src/components/header/QuickSearchButton.tsx b/packages/app/src/components/header/QuickSearchButton.tsx index 0b28e43b09..ffe1fe7e14 100644 --- a/packages/app/src/components/header/QuickSearchButton.tsx +++ b/packages/app/src/components/header/QuickSearchButton.tsx @@ -4,6 +4,20 @@ import { Tooltip } from '@/ui/tooltip'; import { ArrowDownIcon } from '@blocksuite/icons'; import { useModal } from '@/providers/GlobalModalProvider'; import { useTranslation } from '@affine/i18n'; +import { styled } from '@/styles'; + +const StyledIconButtonWithAnimate = styled(IconButton)(() => { + return { + svg: { + transition: 'transform 0.15s ease-in-out', + }, + ':hover': { + svg: { + transform: 'translateY(3px)', + }, + }, + }; +}); export const QuickSearchButton = ({ onClick, ...props @@ -12,7 +26,7 @@ export const QuickSearchButton = ({ const { t } = useTranslation(); return ( - { @@ -21,7 +35,7 @@ export const QuickSearchButton = ({ }} > - + ); }; From 423f0e8e963ca2cce257f016c8192a40df782efe Mon Sep 17 00:00:00 2001 From: QiShaoXuan Date: Wed, 11 Jan 2023 16:37:41 +0800 Subject: [PATCH 3/3] fix: type error --- packages/app/src/providers/app-state-provider/Provider.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/app/src/providers/app-state-provider/Provider.tsx b/packages/app/src/providers/app-state-provider/Provider.tsx index ef7169206e..710bf81853 100644 --- a/packages/app/src/providers/app-state-provider/Provider.tsx +++ b/packages/app/src/providers/app-state-provider/Provider.tsx @@ -100,7 +100,7 @@ export const AppStateProvider = ({ if (workspaceId === currentWorkspace?.id) { return currentWorkspace; } - const workspace = await dataCenter.loadWorkspace(workspaceId); + const workspace = (await dataCenter.loadWorkspace(workspaceId)) ?? null; const pageList = (workspace?.blocksuiteWorkspace?.meta.pageMetas as PageMeta[]) ?? []; setAppState({