mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-27 02:42:25 +08:00
chore: remove currentWorkspaceId & currentMetaWorkspace
This commit is contained in:
@@ -8,7 +8,7 @@ import { useTranslation } from '@affine/i18n';
|
|||||||
|
|
||||||
export const TrashButtonGroup = () => {
|
export const TrashButtonGroup = () => {
|
||||||
const { permanentlyDeletePage } = usePageHelper();
|
const { permanentlyDeletePage } = usePageHelper();
|
||||||
const { currentWorkspaceId } = useAppState();
|
const { currentWorkspace } = useAppState();
|
||||||
const { toggleDeletePage } = usePageHelper();
|
const { toggleDeletePage } = usePageHelper();
|
||||||
const { confirm } = useConfirm();
|
const { confirm } = useConfirm();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
@@ -38,7 +38,7 @@ export const TrashButtonGroup = () => {
|
|||||||
confirmType: 'danger',
|
confirmType: 'danger',
|
||||||
}).then(confirm => {
|
}).then(confirm => {
|
||||||
if (confirm) {
|
if (confirm) {
|
||||||
router.push(`/workspace/${currentWorkspaceId}/all`);
|
router.push(`/workspace/${currentWorkspace?.id}/all`);
|
||||||
permanentlyDeletePage(id);
|
permanentlyDeletePage(id);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ export const PageList = ({
|
|||||||
isTrash?: boolean;
|
isTrash?: boolean;
|
||||||
}) => {
|
}) => {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { currentWorkspaceId } = useAppState();
|
const { currentWorkspace } = useAppState();
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
if (pageList.length === 0) {
|
if (pageList.length === 0) {
|
||||||
return <Empty />;
|
return <Empty />;
|
||||||
@@ -99,7 +99,7 @@ export const PageList = ({
|
|||||||
key={`${pageMeta.id}-${index}`}
|
key={`${pageMeta.id}-${index}`}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
router.push(
|
router.push(
|
||||||
`/workspace/${currentWorkspaceId}/${pageMeta.id}`
|
`/workspace/${currentWorkspace?.id}/${pageMeta.id}`
|
||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -17,10 +17,8 @@ export const Input = (props: {
|
|||||||
const [isComposition, setIsComposition] = useState(false);
|
const [isComposition, setIsComposition] = useState(false);
|
||||||
const [inputValue, setInputValue] = useState('');
|
const [inputValue, setInputValue] = useState('');
|
||||||
const inputRef = useRef<HTMLInputElement>(null);
|
const inputRef = useRef<HTMLInputElement>(null);
|
||||||
const { currentWorkspaceId, workspaceList, currentWorkspace } = useAppState();
|
const { currentWorkspace } = useAppState();
|
||||||
const isPublish = workspaceList.find(
|
|
||||||
meta => String(meta.id) === String(currentWorkspaceId)
|
|
||||||
)?.published;
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
inputRef.current?.addEventListener(
|
inputRef.current?.addEventListener(
|
||||||
'blur',
|
'blur',
|
||||||
@@ -79,7 +77,7 @@ export const Input = (props: {
|
|||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
placeholder={
|
placeholder={
|
||||||
isPublish
|
currentWorkspace?.isPublish
|
||||||
? `Search in ${currentWorkspace?.blocksuiteWorkspace?.meta.name}`
|
? `Search in ${currentWorkspace?.blocksuiteWorkspace?.meta.name}`
|
||||||
: 'Quick Search...'
|
: 'Quick Search...'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,9 +22,9 @@ export const Results = (props: {
|
|||||||
const { triggerQuickSearchModal } = useModal();
|
const { triggerQuickSearchModal } = useModal();
|
||||||
const { openPage } = usePageHelper();
|
const { openPage } = usePageHelper();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { currentWorkspaceId, pageList } = useAppState();
|
const { currentWorkspace, pageList } = useAppState();
|
||||||
const { search } = usePageHelper();
|
const { search } = usePageHelper();
|
||||||
const List = useSwitchToConfig(currentWorkspaceId);
|
const List = useSwitchToConfig(currentWorkspace?.id);
|
||||||
const [results, setResults] = useState(new Map<string, string | undefined>());
|
const [results, setResults] = useState(new Map<string, string | undefined>());
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
@@ -1,15 +1,16 @@
|
|||||||
|
import { FC, SVGProps } from 'react';
|
||||||
import { AllPagesIcon, FavouritesIcon, TrashIcon } from '@blocksuite/icons';
|
import { AllPagesIcon, FavouritesIcon, TrashIcon } from '@blocksuite/icons';
|
||||||
import { useTranslation } from '@affine/i18n';
|
import { useTranslation } from '@affine/i18n';
|
||||||
|
|
||||||
export const useSwitchToConfig = (
|
export const useSwitchToConfig = (
|
||||||
currentWorkspaceId: string
|
currentWorkspaceId?: string
|
||||||
): {
|
): {
|
||||||
title: string;
|
title: string;
|
||||||
href: string;
|
href: string;
|
||||||
icon: React.FC<React.SVGProps<SVGSVGElement>>;
|
icon: FC<SVGProps<SVGSVGElement>>;
|
||||||
}[] => {
|
}[] => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const List = [
|
return [
|
||||||
{
|
{
|
||||||
title: t('All pages'),
|
title: t('All pages'),
|
||||||
href: currentWorkspaceId ? `/workspace/${currentWorkspaceId}/all` : '',
|
href: currentWorkspaceId ? `/workspace/${currentWorkspaceId}/all` : '',
|
||||||
@@ -28,5 +29,4 @@ export const useSwitchToConfig = (
|
|||||||
icon: TrashIcon,
|
icon: TrashIcon,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
return List;
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -22,15 +22,13 @@ const isMac = () => {
|
|||||||
return getUaHelper().isMacOs;
|
return getUaHelper().isMacOs;
|
||||||
};
|
};
|
||||||
export const QuickSearch = ({ open, onClose }: TransitionsModalProps) => {
|
export const QuickSearch = ({ open, onClose }: TransitionsModalProps) => {
|
||||||
const { currentMetaWorkSpace } = useAppState();
|
const { currentWorkspace } = useAppState();
|
||||||
|
|
||||||
const [query, setQuery] = useState('');
|
const [query, setQuery] = useState('');
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
const [showCreatePage, setShowCreatePage] = useState(true);
|
const [showCreatePage, setShowCreatePage] = useState(true);
|
||||||
const { triggerQuickSearchModal } = useModal();
|
const { triggerQuickSearchModal } = useModal();
|
||||||
|
|
||||||
const isPublish = currentMetaWorkSpace?.published;
|
|
||||||
|
|
||||||
// Add ‘⌘+K’ shortcut keys as switches
|
// Add ‘⌘+K’ shortcut keys as switches
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const down = (e: KeyboardEvent) => {
|
const down = (e: KeyboardEvent) => {
|
||||||
@@ -96,7 +94,7 @@ export const QuickSearch = ({ open, onClose }: TransitionsModalProps) => {
|
|||||||
setShowCreatePage={setShowCreatePage}
|
setShowCreatePage={setShowCreatePage}
|
||||||
/>
|
/>
|
||||||
</StyledContent>
|
</StyledContent>
|
||||||
{isPublish ? (
|
{currentWorkspace?.isPublish ? (
|
||||||
<></>
|
<></>
|
||||||
) : showCreatePage ? (
|
) : showCreatePage ? (
|
||||||
<>
|
<>
|
||||||
|
|||||||
@@ -34,8 +34,6 @@ import { useConfirm } from '@/providers/ConfirmProvider';
|
|||||||
export const MembersPage = ({ workspace }: { workspace: WorkspaceUnit }) => {
|
export const MembersPage = ({ workspace }: { workspace: WorkspaceUnit }) => {
|
||||||
const [isInviteModalShow, setIsInviteModalShow] = useState(false);
|
const [isInviteModalShow, setIsInviteModalShow] = useState(false);
|
||||||
|
|
||||||
// const { currentMetaWorkSpace, currentWorkspace, dataCenter } = useAppState();
|
|
||||||
|
|
||||||
const [members, setMembers] = useState<[{ name: string; email: string }?]>(
|
const [members, setMembers] = useState<[{ name: string; email: string }?]>(
|
||||||
[]
|
[]
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -41,7 +41,6 @@ export const GeneralPage = ({ workspace }: { workspace: WorkspaceUnit }) => {
|
|||||||
setShowLeave(false);
|
setShowLeave(false);
|
||||||
};
|
};
|
||||||
const handleUpdateWorkspaceName = () => {
|
const handleUpdateWorkspaceName = () => {
|
||||||
console.log('currentWorkspace: ', currentWorkspace);
|
|
||||||
currentWorkspace &&
|
currentWorkspace &&
|
||||||
updateWorkspace({ name: workspaceName }, currentWorkspace);
|
updateWorkspace({ name: workspaceName }, currentWorkspace);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { WorkspaceAvatar } from '@/components/workspace-avatar';
|
|||||||
import { useAppState } from '@/providers/app-state-provider';
|
import { useAppState } from '@/providers/app-state-provider';
|
||||||
export const WorkspaceSelector = () => {
|
export const WorkspaceSelector = () => {
|
||||||
const [workspaceListShow, setWorkspaceListShow] = useState(false);
|
const [workspaceListShow, setWorkspaceListShow] = useState(false);
|
||||||
const { currentMetaWorkSpace, workspaceList } = useAppState();
|
const { currentWorkspace, workspaceList } = useAppState();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (workspaceList.length === 0) {
|
if (workspaceList.length === 0) {
|
||||||
@@ -23,7 +23,7 @@ export const WorkspaceSelector = () => {
|
|||||||
<Avatar
|
<Avatar
|
||||||
alt="Affine"
|
alt="Affine"
|
||||||
data-testid="workspace-avatar"
|
data-testid="workspace-avatar"
|
||||||
src={currentMetaWorkSpace?.avatar}
|
src={currentWorkspace?.avatar}
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
@@ -32,13 +32,13 @@ export const WorkspaceSelector = () => {
|
|||||||
>
|
>
|
||||||
<WorkspaceAvatar
|
<WorkspaceAvatar
|
||||||
size={28}
|
size={28}
|
||||||
name={currentMetaWorkSpace?.name ?? 'AFFiNE'}
|
name={currentWorkspace?.name ?? 'AFFiNE'}
|
||||||
avatar={currentMetaWorkSpace?.avatar ?? ''}
|
avatar={currentWorkspace?.avatar ?? ''}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</Avatar>
|
</Avatar>
|
||||||
<WorkspaceName data-testid="workspace-name">
|
<WorkspaceName data-testid="workspace-name">
|
||||||
{currentMetaWorkSpace?.name ?? 'AFFiNE'}
|
{currentWorkspace?.name ?? 'AFFiNE'}
|
||||||
</WorkspaceName>
|
</WorkspaceName>
|
||||||
</SelectorWrapper>
|
</SelectorWrapper>
|
||||||
<WorkspaceModal
|
<WorkspaceModal
|
||||||
|
|||||||
@@ -67,13 +67,13 @@ const FavoriteList = ({ showList }: { showList: boolean }) => {
|
|||||||
export const WorkSpaceSliderBar = () => {
|
export const WorkSpaceSliderBar = () => {
|
||||||
const { triggerQuickSearchModal, triggerImportModal } = useModal();
|
const { triggerQuickSearchModal, triggerImportModal } = useModal();
|
||||||
const [showSubFavorite, setShowSubFavorite] = useState(true);
|
const [showSubFavorite, setShowSubFavorite] = useState(true);
|
||||||
const { currentWorkspaceId } = useAppState();
|
const { currentWorkspace } = useAppState();
|
||||||
const { openPage, createPage } = usePageHelper();
|
const { openPage, createPage } = usePageHelper();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [showTip, setShowTip] = useState(false);
|
const [showTip, setShowTip] = useState(false);
|
||||||
const [show, setShow] = useLocalStorage('AFFiNE_SLIDE_BAR', false, true);
|
const [show, setShow] = useLocalStorage('AFFiNE_SLIDE_BAR', false, true);
|
||||||
|
const currentWorkspaceId = currentWorkspace?.id;
|
||||||
const paths = {
|
const paths = {
|
||||||
all: currentWorkspaceId ? `/workspace/${currentWorkspaceId}/all` : '',
|
all: currentWorkspaceId ? `/workspace/${currentWorkspaceId}/all` : '',
|
||||||
favorite: currentWorkspaceId
|
favorite: currentWorkspaceId
|
||||||
|
|||||||
@@ -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,
|
|
||||||
};
|
|
||||||
};
|
|
||||||
@@ -36,7 +36,7 @@ const getPageMeta = (workspace: WorkspaceUnit | null, pageId: string) => {
|
|||||||
export const usePageHelper = (): EditorHandlers => {
|
export const usePageHelper = (): EditorHandlers => {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const changePageMeta = useChangePageMeta();
|
const changePageMeta = useChangePageMeta();
|
||||||
const { currentWorkspace, editor, currentWorkspaceId } = useAppState();
|
const { currentWorkspace, editor } = useAppState();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
createPage: ({
|
createPage: ({
|
||||||
@@ -109,11 +109,11 @@ export const usePageHelper = (): EditorHandlers => {
|
|||||||
pageId = pageId.replace('space:', '');
|
pageId = pageId.replace('space:', '');
|
||||||
|
|
||||||
if (newTab) {
|
if (newTab) {
|
||||||
window.open(`/workspace/${currentWorkspaceId}/${pageId}`, '_blank');
|
window.open(`/workspace/${currentWorkspace?.id}/${pageId}`, '_blank');
|
||||||
return Promise.resolve(true);
|
return Promise.resolve(true);
|
||||||
}
|
}
|
||||||
return router.push({
|
return router.push({
|
||||||
pathname: `/workspace/${currentWorkspaceId}/${pageId}`,
|
pathname: `/workspace/${currentWorkspace?.id}/${pageId}`,
|
||||||
query,
|
query,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ import router from 'next/router';
|
|||||||
|
|
||||||
export const useWorkspaceHelper = () => {
|
export const useWorkspaceHelper = () => {
|
||||||
const { confirm } = useConfirm();
|
const { confirm } = useConfirm();
|
||||||
const { dataCenter, currentWorkspace, user, login, currentMetaWorkSpace } =
|
const { dataCenter, currentWorkspace, user, login } = useAppState();
|
||||||
useAppState();
|
|
||||||
const createWorkspace = async (name: string) => {
|
const createWorkspace = async (name: string) => {
|
||||||
const workspaceInfo = await dataCenter.createWorkspace({
|
const workspaceInfo = await dataCenter.createWorkspace({
|
||||||
name: name,
|
name: name,
|
||||||
@@ -58,8 +57,8 @@ export const useWorkspaceHelper = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const inviteMember = async (email: string) => {
|
const inviteMember = async (email: string) => {
|
||||||
currentMetaWorkSpace &&
|
currentWorkspace &&
|
||||||
(await dataCenter.inviteMember(currentMetaWorkSpace?.id, email));
|
(await dataCenter.inviteMember(currentWorkspace?.id, email));
|
||||||
};
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import usePageHelper from '@/hooks/use-page-helper';
|
|||||||
|
|
||||||
const WorkspaceIndex = () => {
|
const WorkspaceIndex = () => {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { currentWorkspaceId, currentWorkspace } = useAppState();
|
const { currentWorkspace } = useAppState();
|
||||||
const { createPage } = usePageHelper();
|
const { createPage } = usePageHelper();
|
||||||
const { workspaceLoaded, activeWorkspaceId } = useEnsureWorkspace();
|
const { workspaceLoaded, activeWorkspaceId } = useEnsureWorkspace();
|
||||||
|
|
||||||
@@ -29,7 +29,6 @@ const WorkspaceIndex = () => {
|
|||||||
initPage();
|
initPage();
|
||||||
}, [
|
}, [
|
||||||
currentWorkspace,
|
currentWorkspace,
|
||||||
currentWorkspaceId,
|
|
||||||
createPage,
|
createPage,
|
||||||
router,
|
router,
|
||||||
workspaceLoaded,
|
workspaceLoaded,
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ const tabMap: {
|
|||||||
];
|
];
|
||||||
|
|
||||||
const WorkspaceSetting = () => {
|
const WorkspaceSetting = () => {
|
||||||
const { currentMetaWorkSpace } = useAppState();
|
const { currentWorkspace } = useAppState();
|
||||||
|
|
||||||
const [activeTab, setActiveTab] = useState<TabNames>(tabMap[0].name);
|
const [activeTab, setActiveTab] = useState<TabNames>(tabMap[0].name);
|
||||||
const handleTabChange = (tab: TabNames) => {
|
const handleTabChange = (tab: TabNames) => {
|
||||||
@@ -98,7 +98,7 @@ const WorkspaceSetting = () => {
|
|||||||
</StyledSettingSidebar>
|
</StyledSettingSidebar>
|
||||||
|
|
||||||
<StyledSettingContent>
|
<StyledSettingContent>
|
||||||
{currentMetaWorkSpace && activeTabPanelRender?.(currentMetaWorkSpace)}
|
{currentWorkspace && activeTabPanelRender?.(currentWorkspace)}
|
||||||
</StyledSettingContent>
|
</StyledSettingContent>
|
||||||
</StyledSettingContainer>
|
</StyledSettingContainer>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -6,14 +6,14 @@ import { PageLoading } from '@/components/loading';
|
|||||||
|
|
||||||
export const WorkspaceIndex = () => {
|
export const WorkspaceIndex = () => {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { currentWorkspaceId } = useAppState();
|
const { currentWorkspace } = useAppState();
|
||||||
const { workspaceLoaded } = useEnsureWorkspace();
|
const { workspaceLoaded } = useEnsureWorkspace();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (workspaceLoaded) {
|
if (workspaceLoaded) {
|
||||||
router.push(`/workspace/${currentWorkspaceId}`);
|
router.push(`/workspace/${currentWorkspace?.id}`);
|
||||||
}
|
}
|
||||||
}, [currentWorkspaceId, router, workspaceLoaded]);
|
}, [currentWorkspace, router, workspaceLoaded]);
|
||||||
|
|
||||||
return <PageLoading />;
|
return <PageLoading />;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import {
|
|||||||
PageMeta,
|
PageMeta,
|
||||||
} from './interface';
|
} from './interface';
|
||||||
import { createDefaultWorkspace } from './utils';
|
import { createDefaultWorkspace } from './utils';
|
||||||
import { WorkspaceUnit, User } from '@affine/datacenter';
|
import { User } from '@affine/datacenter';
|
||||||
|
|
||||||
type AppStateContextProps = PropsWithChildren<Record<string, unknown>>;
|
type AppStateContextProps = PropsWithChildren<Record<string, unknown>>;
|
||||||
|
|
||||||
@@ -34,13 +34,11 @@ export const AppStateProvider = ({
|
|||||||
dataCenter,
|
dataCenter,
|
||||||
user: (await dataCenter.getUserInfo()) || null,
|
user: (await dataCenter.getUserInfo()) || null,
|
||||||
workspaceList: dataCenter.workspaces,
|
workspaceList: dataCenter.workspaces,
|
||||||
currentWorkspaceId: '',
|
|
||||||
currentWorkspace: null,
|
currentWorkspace: null,
|
||||||
pageList: [],
|
pageList: [],
|
||||||
currentPage: null,
|
currentPage: null,
|
||||||
editor: null,
|
editor: null,
|
||||||
synced: true,
|
synced: true,
|
||||||
currentMetaWorkSpace: null,
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -95,27 +93,19 @@ export const AppStateProvider = ({
|
|||||||
|
|
||||||
const loadWorkspace = useRef<AppStateFunction['loadWorkspace']>();
|
const loadWorkspace = useRef<AppStateFunction['loadWorkspace']>();
|
||||||
loadWorkspace.current = async (workspaceId: string) => {
|
loadWorkspace.current = async (workspaceId: string) => {
|
||||||
const { dataCenter, workspaceList, currentWorkspaceId, currentWorkspace } =
|
const { dataCenter, workspaceList, currentWorkspace } = appState;
|
||||||
appState;
|
|
||||||
if (!workspaceList.find(v => v.id.toString() === workspaceId)) {
|
if (!workspaceList.find(v => v.id.toString() === workspaceId)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (workspaceId === currentWorkspaceId) {
|
if (workspaceId === currentWorkspace?.id) {
|
||||||
return currentWorkspace;
|
return currentWorkspace;
|
||||||
}
|
}
|
||||||
const workspace = await dataCenter.loadWorkspace(workspaceId);
|
const workspace = await dataCenter.loadWorkspace(workspaceId);
|
||||||
const currentMetaWorkSpace = dataCenter.workspaces.find(
|
|
||||||
(item: WorkspaceUnit) => {
|
|
||||||
return item.id.toString() === workspace.id;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
const pageList =
|
const pageList =
|
||||||
(workspace?.blocksuiteWorkspace?.meta.pageMetas as PageMeta[]) ?? [];
|
(workspace?.blocksuiteWorkspace?.meta.pageMetas as PageMeta[]) ?? [];
|
||||||
setAppState({
|
setAppState({
|
||||||
...appState,
|
...appState,
|
||||||
currentWorkspace: workspace,
|
currentWorkspace: workspace,
|
||||||
currentWorkspaceId: workspaceId,
|
|
||||||
currentMetaWorkSpace: currentMetaWorkSpace ?? null,
|
|
||||||
pageList: pageList,
|
pageList: pageList,
|
||||||
currentPage: null,
|
currentPage: null,
|
||||||
editor: null,
|
editor: null,
|
||||||
|
|||||||
@@ -19,8 +19,6 @@ export type AppStateValue = {
|
|||||||
user: User | null;
|
user: User | null;
|
||||||
workspaceList: WorkspaceUnit[];
|
workspaceList: WorkspaceUnit[];
|
||||||
currentWorkspace: WorkspaceUnit | null;
|
currentWorkspace: WorkspaceUnit | null;
|
||||||
currentMetaWorkSpace: WorkspaceUnit | null;
|
|
||||||
currentWorkspaceId: string;
|
|
||||||
pageList: PageMeta[];
|
pageList: PageMeta[];
|
||||||
currentPage: StorePage | null;
|
currentPage: StorePage | null;
|
||||||
editor?: EditorContainer | null;
|
editor?: EditorContainer | null;
|
||||||
|
|||||||
24
pnpm-lock.yaml
generated
24
pnpm-lock.yaml
generated
@@ -2967,7 +2967,6 @@ packages:
|
|||||||
|
|
||||||
/@next/env/13.1.0:
|
/@next/env/13.1.0:
|
||||||
resolution: {integrity: sha512-6iNixFzCndH+Bl4FetQzOMjxCJqg8fs0LAlZviig1K6mIjOWH2m2oPcHcOg1Ta5VCe7Bx5KG1Hs+NrWDUkBt9A==}
|
resolution: {integrity: sha512-6iNixFzCndH+Bl4FetQzOMjxCJqg8fs0LAlZviig1K6mIjOWH2m2oPcHcOg1Ta5VCe7Bx5KG1Hs+NrWDUkBt9A==}
|
||||||
dev: false
|
|
||||||
|
|
||||||
/@next/eslint-plugin-next/12.3.1:
|
/@next/eslint-plugin-next/12.3.1:
|
||||||
resolution: {integrity: sha512-sw+lTf6r6P0j+g/n9y4qdWWI2syPqZx+uc0+B/fRENqfR3KpSid6MIKqc9gNwGhJASazEQ5b3w8h4cAET213jw==}
|
resolution: {integrity: sha512-sw+lTf6r6P0j+g/n9y4qdWWI2syPqZx+uc0+B/fRENqfR3KpSid6MIKqc9gNwGhJASazEQ5b3w8h4cAET213jw==}
|
||||||
@@ -2990,7 +2989,6 @@ packages:
|
|||||||
cpu: [arm]
|
cpu: [arm]
|
||||||
os: [android]
|
os: [android]
|
||||||
requiresBuild: true
|
requiresBuild: true
|
||||||
dev: false
|
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
/@next/swc-android-arm64/12.3.1:
|
/@next/swc-android-arm64/12.3.1:
|
||||||
@@ -3008,7 +3006,6 @@ packages:
|
|||||||
cpu: [arm64]
|
cpu: [arm64]
|
||||||
os: [android]
|
os: [android]
|
||||||
requiresBuild: true
|
requiresBuild: true
|
||||||
dev: false
|
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
/@next/swc-darwin-arm64/12.3.1:
|
/@next/swc-darwin-arm64/12.3.1:
|
||||||
@@ -3026,7 +3023,6 @@ packages:
|
|||||||
cpu: [arm64]
|
cpu: [arm64]
|
||||||
os: [darwin]
|
os: [darwin]
|
||||||
requiresBuild: true
|
requiresBuild: true
|
||||||
dev: false
|
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
/@next/swc-darwin-x64/12.3.1:
|
/@next/swc-darwin-x64/12.3.1:
|
||||||
@@ -3044,7 +3040,6 @@ packages:
|
|||||||
cpu: [x64]
|
cpu: [x64]
|
||||||
os: [darwin]
|
os: [darwin]
|
||||||
requiresBuild: true
|
requiresBuild: true
|
||||||
dev: false
|
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
/@next/swc-freebsd-x64/12.3.1:
|
/@next/swc-freebsd-x64/12.3.1:
|
||||||
@@ -3062,7 +3057,6 @@ packages:
|
|||||||
cpu: [x64]
|
cpu: [x64]
|
||||||
os: [freebsd]
|
os: [freebsd]
|
||||||
requiresBuild: true
|
requiresBuild: true
|
||||||
dev: false
|
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
/@next/swc-linux-arm-gnueabihf/12.3.1:
|
/@next/swc-linux-arm-gnueabihf/12.3.1:
|
||||||
@@ -3080,7 +3074,6 @@ packages:
|
|||||||
cpu: [arm]
|
cpu: [arm]
|
||||||
os: [linux]
|
os: [linux]
|
||||||
requiresBuild: true
|
requiresBuild: true
|
||||||
dev: false
|
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
/@next/swc-linux-arm64-gnu/12.3.1:
|
/@next/swc-linux-arm64-gnu/12.3.1:
|
||||||
@@ -3098,7 +3091,6 @@ packages:
|
|||||||
cpu: [arm64]
|
cpu: [arm64]
|
||||||
os: [linux]
|
os: [linux]
|
||||||
requiresBuild: true
|
requiresBuild: true
|
||||||
dev: false
|
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
/@next/swc-linux-arm64-musl/12.3.1:
|
/@next/swc-linux-arm64-musl/12.3.1:
|
||||||
@@ -3116,7 +3108,6 @@ packages:
|
|||||||
cpu: [arm64]
|
cpu: [arm64]
|
||||||
os: [linux]
|
os: [linux]
|
||||||
requiresBuild: true
|
requiresBuild: true
|
||||||
dev: false
|
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
/@next/swc-linux-x64-gnu/12.3.1:
|
/@next/swc-linux-x64-gnu/12.3.1:
|
||||||
@@ -3134,7 +3125,6 @@ packages:
|
|||||||
cpu: [x64]
|
cpu: [x64]
|
||||||
os: [linux]
|
os: [linux]
|
||||||
requiresBuild: true
|
requiresBuild: true
|
||||||
dev: false
|
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
/@next/swc-linux-x64-musl/12.3.1:
|
/@next/swc-linux-x64-musl/12.3.1:
|
||||||
@@ -3152,7 +3142,6 @@ packages:
|
|||||||
cpu: [x64]
|
cpu: [x64]
|
||||||
os: [linux]
|
os: [linux]
|
||||||
requiresBuild: true
|
requiresBuild: true
|
||||||
dev: false
|
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
/@next/swc-win32-arm64-msvc/12.3.1:
|
/@next/swc-win32-arm64-msvc/12.3.1:
|
||||||
@@ -3170,7 +3159,6 @@ packages:
|
|||||||
cpu: [arm64]
|
cpu: [arm64]
|
||||||
os: [win32]
|
os: [win32]
|
||||||
requiresBuild: true
|
requiresBuild: true
|
||||||
dev: false
|
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
/@next/swc-win32-ia32-msvc/12.3.1:
|
/@next/swc-win32-ia32-msvc/12.3.1:
|
||||||
@@ -3188,7 +3176,6 @@ packages:
|
|||||||
cpu: [ia32]
|
cpu: [ia32]
|
||||||
os: [win32]
|
os: [win32]
|
||||||
requiresBuild: true
|
requiresBuild: true
|
||||||
dev: false
|
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
/@next/swc-win32-x64-msvc/12.3.1:
|
/@next/swc-win32-x64-msvc/12.3.1:
|
||||||
@@ -3206,7 +3193,6 @@ packages:
|
|||||||
cpu: [x64]
|
cpu: [x64]
|
||||||
os: [win32]
|
os: [win32]
|
||||||
requiresBuild: true
|
requiresBuild: true
|
||||||
dev: false
|
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
/@nodelib/fs.scandir/2.1.5:
|
/@nodelib/fs.scandir/2.1.5:
|
||||||
@@ -3569,7 +3555,6 @@ packages:
|
|||||||
resolution: {integrity: sha512-4C7nX/dvpzB7za4Ql9K81xK3HPxCpHMgwTZVyf+9JQ6VUbn9jjZVN7/Nkdz/Ugzs2CSjqnL/UPXroiVBVHUWUw==}
|
resolution: {integrity: sha512-4C7nX/dvpzB7za4Ql9K81xK3HPxCpHMgwTZVyf+9JQ6VUbn9jjZVN7/Nkdz/Ugzs2CSjqnL/UPXroiVBVHUWUw==}
|
||||||
dependencies:
|
dependencies:
|
||||||
tslib: 2.4.0
|
tslib: 2.4.0
|
||||||
dev: false
|
|
||||||
|
|
||||||
/@szmarczak/http-timer/5.0.1:
|
/@szmarczak/http-timer/5.0.1:
|
||||||
resolution: {integrity: sha512-+PmQX0PiAYPMeVYe237LJAYvOMYW1j2rH5YROyS3b4CTVJum34HfRvKvAzozHAQG0TnHNdUfY9nCeUyRAs//cw==}
|
resolution: {integrity: sha512-+PmQX0PiAYPMeVYe237LJAYvOMYW1j2rH5YROyS3b4CTVJum34HfRvKvAzozHAQG0TnHNdUfY9nCeUyRAs//cw==}
|
||||||
@@ -4536,7 +4521,6 @@ packages:
|
|||||||
|
|
||||||
/client-only/0.0.1:
|
/client-only/0.0.1:
|
||||||
resolution: {integrity: sha512-IV3Ou0jSMzZrd3pZ48nLkT9DA7Ag1pnPzaiQhpW7c3RbcqqzvzzVu+L8gfqMp/8IM2MQtSiqaCxrrcfu8I8rMA==}
|
resolution: {integrity: sha512-IV3Ou0jSMzZrd3pZ48nLkT9DA7Ag1pnPzaiQhpW7c3RbcqqzvzzVu+L8gfqMp/8IM2MQtSiqaCxrrcfu8I8rMA==}
|
||||||
dev: false
|
|
||||||
|
|
||||||
/cliui/6.0.0:
|
/cliui/6.0.0:
|
||||||
resolution: {integrity: sha512-t6wbgtoCXvAzst7QgXxJYqPt0usEfbgQdftEPbLL/cvv6HPE5VgvqCuAIDR0NgU52ds6rFwqrgakNLrHEjCbrQ==}
|
resolution: {integrity: sha512-t6wbgtoCXvAzst7QgXxJYqPt0usEfbgQdftEPbLL/cvv6HPE5VgvqCuAIDR0NgU52ds6rFwqrgakNLrHEjCbrQ==}
|
||||||
@@ -7468,7 +7452,6 @@ packages:
|
|||||||
resolution: {integrity: sha512-MqBkQh/OHTS2egovRtLk45wEyNXwF+cokD+1YPf9u5VfJiRdAiRwB2froX5Co9Rh20xs4siNPm8naNotSD6RBw==}
|
resolution: {integrity: sha512-MqBkQh/OHTS2egovRtLk45wEyNXwF+cokD+1YPf9u5VfJiRdAiRwB2froX5Co9Rh20xs4siNPm8naNotSD6RBw==}
|
||||||
engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1}
|
engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1}
|
||||||
hasBin: true
|
hasBin: true
|
||||||
dev: false
|
|
||||||
|
|
||||||
/natural-compare-lite/1.4.0:
|
/natural-compare-lite/1.4.0:
|
||||||
resolution: {integrity: sha512-Tj+HTDSJJKaZnfiuw+iaF9skdPpTo2GtEly5JHnWV/hfv2Qj/9RKsGISQtLh2ox3l5EAGw487hnBee0sIJ6v2g==}
|
resolution: {integrity: sha512-Tj+HTDSJJKaZnfiuw+iaF9skdPpTo2GtEly5JHnWV/hfv2Qj/9RKsGISQtLh2ox3l5EAGw487hnBee0sIJ6v2g==}
|
||||||
@@ -7591,7 +7574,6 @@ packages:
|
|||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- '@babel/core'
|
- '@babel/core'
|
||||||
- babel-plugin-macros
|
- babel-plugin-macros
|
||||||
dev: false
|
|
||||||
|
|
||||||
/node-domexception/1.0.0:
|
/node-domexception/1.0.0:
|
||||||
resolution: {integrity: sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==}
|
resolution: {integrity: sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==}
|
||||||
@@ -7942,7 +7924,6 @@ packages:
|
|||||||
nanoid: 3.3.4
|
nanoid: 3.3.4
|
||||||
picocolors: 1.0.0
|
picocolors: 1.0.0
|
||||||
source-map-js: 1.0.2
|
source-map-js: 1.0.2
|
||||||
dev: false
|
|
||||||
|
|
||||||
/preferred-pm/3.0.3:
|
/preferred-pm/3.0.3:
|
||||||
resolution: {integrity: sha512-+wZgbxNES/KlJs9q40F/1sfOd/j7f1O9JaHcW5Dsn3aUUOZg3L2bjpVUcKV2jvtElYfoTuQiNeMfQJ4kwUAhCQ==}
|
resolution: {integrity: sha512-+wZgbxNES/KlJs9q40F/1sfOd/j7f1O9JaHcW5Dsn3aUUOZg3L2bjpVUcKV2jvtElYfoTuQiNeMfQJ4kwUAhCQ==}
|
||||||
@@ -8112,7 +8093,6 @@ packages:
|
|||||||
loose-envify: 1.4.0
|
loose-envify: 1.4.0
|
||||||
react: 18.2.0
|
react: 18.2.0
|
||||||
scheduler: 0.23.0
|
scheduler: 0.23.0
|
||||||
dev: false
|
|
||||||
|
|
||||||
/react-i18next/11.18.6_i18next@21.10.0:
|
/react-i18next/11.18.6_i18next@21.10.0:
|
||||||
resolution: {integrity: sha512-yHb2F9BiT0lqoQDt8loZ5gWP331GwctHz9tYQ8A2EIEUu+CcEdjBLQWli1USG3RdWQt3W+jqQLg/d4rrQR96LA==}
|
resolution: {integrity: sha512-yHb2F9BiT0lqoQDt8loZ5gWP331GwctHz9tYQ8A2EIEUu+CcEdjBLQWli1USG3RdWQt3W+jqQLg/d4rrQR96LA==}
|
||||||
@@ -8209,7 +8189,6 @@ packages:
|
|||||||
engines: {node: '>=0.10.0'}
|
engines: {node: '>=0.10.0'}
|
||||||
dependencies:
|
dependencies:
|
||||||
loose-envify: 1.4.0
|
loose-envify: 1.4.0
|
||||||
dev: false
|
|
||||||
|
|
||||||
/read-pkg-up/7.0.1:
|
/read-pkg-up/7.0.1:
|
||||||
resolution: {integrity: sha512-zK0TB7Xd6JpCLmlLmufqykGE+/TlOePD6qKClNW7hHDKFh/J7/7gCWGR7joEQEW1bKq3a3yUZSObOoWLFQ4ohg==}
|
resolution: {integrity: sha512-zK0TB7Xd6JpCLmlLmufqykGE+/TlOePD6qKClNW7hHDKFh/J7/7gCWGR7joEQEW1bKq3a3yUZSObOoWLFQ4ohg==}
|
||||||
@@ -8487,7 +8466,6 @@ packages:
|
|||||||
resolution: {integrity: sha512-CtuThmgHNg7zIZWAXi3AsyIzA3n4xx7aNyjwC2VJldO2LMVDhFK+63xGqq6CsJH4rTAt6/M+N4GhZiDYPx9eUw==}
|
resolution: {integrity: sha512-CtuThmgHNg7zIZWAXi3AsyIzA3n4xx7aNyjwC2VJldO2LMVDhFK+63xGqq6CsJH4rTAt6/M+N4GhZiDYPx9eUw==}
|
||||||
dependencies:
|
dependencies:
|
||||||
loose-envify: 1.4.0
|
loose-envify: 1.4.0
|
||||||
dev: false
|
|
||||||
|
|
||||||
/schema-utils/2.7.1:
|
/schema-utils/2.7.1:
|
||||||
resolution: {integrity: sha512-SHiNtMOUGWBQJwzISiVYKu82GiV4QYGePp3odlY1tuKO7gPtphAT5R/py0fA6xtbgLL/RvtJZnU9b8s0F1q0Xg==}
|
resolution: {integrity: sha512-SHiNtMOUGWBQJwzISiVYKu82GiV4QYGePp3odlY1tuKO7gPtphAT5R/py0fA6xtbgLL/RvtJZnU9b8s0F1q0Xg==}
|
||||||
@@ -8646,7 +8624,6 @@ packages:
|
|||||||
/source-map-js/1.0.2:
|
/source-map-js/1.0.2:
|
||||||
resolution: {integrity: sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==}
|
resolution: {integrity: sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==}
|
||||||
engines: {node: '>=0.10.0'}
|
engines: {node: '>=0.10.0'}
|
||||||
dev: false
|
|
||||||
|
|
||||||
/source-map-support/0.5.13:
|
/source-map-support/0.5.13:
|
||||||
resolution: {integrity: sha512-SHSKFHadjVA5oR4PPqhtAVdcBWwRYVd6g6cAXnIbRiIwc2EhPrTuKUBdSLvlEKyIP3GCf89fltvcZiP9MMFA1w==}
|
resolution: {integrity: sha512-SHSKFHadjVA5oR4PPqhtAVdcBWwRYVd6g6cAXnIbRiIwc2EhPrTuKUBdSLvlEKyIP3GCf89fltvcZiP9MMFA1w==}
|
||||||
@@ -8895,7 +8872,6 @@ packages:
|
|||||||
dependencies:
|
dependencies:
|
||||||
client-only: 0.0.1
|
client-only: 0.0.1
|
||||||
react: 18.2.0
|
react: 18.2.0
|
||||||
dev: false
|
|
||||||
|
|
||||||
/stylis/4.0.13:
|
/stylis/4.0.13:
|
||||||
resolution: {integrity: sha512-xGPXiFVl4YED9Jh7Euv2V220mriG9u4B2TA6Ybjc1catrstKD2PpIdU3U0RKpkVBC2EhmL/F0sPCr9vrFTNRag==}
|
resolution: {integrity: sha512-xGPXiFVl4YED9Jh7Euv2V220mriG9u4B2TA6Ybjc1catrstKD2PpIdU3U0RKpkVBC2EhmL/F0sPCr9vrFTNRag==}
|
||||||
|
|||||||
Reference in New Issue
Block a user