refactor : improved performance, independent running promise in parallel

This commit is contained in:
CarlosZoft
2022-08-06 14:26:37 -03:00
parent fb81d1f8ff
commit 5528ed683b
2 changed files with 9 additions and 16 deletions

View File

@@ -10,16 +10,13 @@ export function WorkspaceHome() {
useEffect(() => { useEffect(() => {
const navigate_to_user_initial_page = async () => { const navigate_to_user_initial_page = async () => {
const recent_pages = await services.api.userConfig.getRecentPages( const [recent_pages, user_initial_page_id] = await Promise.all([
workspace_id, services.api.userConfig.getRecentPages(workspace_id, user.id),
user.id services.api.userConfig.getUserInitialPage(
);
const user_initial_page_id =
await services.api.userConfig.getUserInitialPage(
workspace_id, workspace_id,
user.id user.id
); ),
]);
if (recent_pages.length === 0) { if (recent_pages.length === 0) {
await services.api.editorBlock.copyTemplateToPage( await services.api.editorBlock.copyTemplateToPage(
workspace_id, workspace_id,

View File

@@ -95,15 +95,11 @@ export const WorkspaceName = () => {
if (!currentSpaceId) { if (!currentSpaceId) {
return; return;
} }
const [name, workspaceId] = await Promise.all([
const name = await services.api.userConfig.getWorkspaceName( services.api.userConfig.getWorkspaceName(currentSpaceId),
currentSpaceId services.api.userConfig.getWorkspaceId(currentSpaceId),
); ]);
setWorkspaceName(name); setWorkspaceName(name);
const workspaceId = await services.api.userConfig.getWorkspaceId(
currentSpaceId
);
setWorkspaceId(workspaceId); setWorkspaceId(workspaceId);
}, [currentSpaceId]); }, [currentSpaceId]);