feat(electron): track router history (#2336)

Co-authored-by: Peng Xiao <pengxiao@outlook.com>
This commit is contained in:
Himself65
2023-05-14 23:13:30 -07:00
committed by GitHub
parent e5330b1917
commit 23b4f9ee12
7 changed files with 219 additions and 7 deletions

View File

@@ -23,8 +23,9 @@ import type { Page } from '@blocksuite/store';
import { useAtom, useAtomValue } from 'jotai';
import type { ReactElement } from 'react';
import type React from 'react';
import { useCallback, useEffect } from 'react';
import { useCallback, useEffect, useMemo } from 'react';
import { useHistoryAtom } from '../../atoms/history';
import type { AllWorkspace } from '../../shared';
import FavoriteList from '../pure/workspace-slider-bar/favorite/favorite-list';
import { WorkspaceSelector } from '../pure/workspace-slider-bar/WorkspaceSelector';
@@ -115,10 +116,22 @@ export const RootAppSidebar = ({
}, [sidebarOpen, setSidebarOpen]);
const clientUpdateAvailable = useAtomValue(updateAvailableAtom);
const [history, setHistory] = useHistoryAtom();
const router = useMemo(() => {
return {
forward: () => {
setHistory(true);
},
back: () => {
setHistory(false);
},
history,
};
}, [history, setHistory]);
return (
<>
<AppSidebar>
<AppSidebar router={router}>
<SidebarContainer>
<WorkspaceSelector
currentWorkspace={currentWorkspace}