Better opening workspaces and redirect workspace to recent request

This commit is contained in:
Gregory Schier
2023-04-11 11:11:36 -07:00
parent deeefdcfbf
commit a38691ed53
11 changed files with 146 additions and 70 deletions

View File

@@ -1,13 +1,18 @@
import { useEffect } from 'react';
import { createGlobalState, useEffectOnce, useLocalStorage } from 'react-use';
import { useActiveRequestId } from './useActiveRequestId';
import { useActiveWorkspaceId } from './useActiveWorkspaceId';
const useHistoryState = createGlobalState<string[]>([]);
export function useRecentRequests() {
const [history, setHistory] = useHistoryState();
const activeWorkspaceId = useActiveWorkspaceId();
const activeRequestId = useActiveRequestId();
const [lsState, setLSState] = useLocalStorage<string[]>('recent_requests', []);
const [history, setHistory] = useHistoryState();
const [lsState, setLSState] = useLocalStorage<string[]>(
'recent_requests::' + activeWorkspaceId,
[],
);
useEffect(() => {
setLSState(history);