Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | 12x 12x 12x 12x 6x 6x 6x 6x 6x 2x 2x 4x 6x 12x | import { useEffect, useRef, useState } from 'react';
import { useNavigate } from 'react-router-dom';
import type { AppDispatch } from '@/store';
import { PROJECT_PATHS } from '@/shared/constants';
import { activeProjectService } from '@/entities/settings/model';
export function useRestoreProject(dispatch: AppDispatch, projectId: string | undefined) {
const navigate = useNavigate();
const attempted = useRef(false);
const [loading, setLoading] = useState(true);
useEffect(() => {
Iif (attempted.current) return;
attempted.current = true;
const restoreProject = async () => {
const ok = await activeProjectService.restoreIntoEditor(dispatch, projectId);
if (!ok) {
navigate(PROJECT_PATHS.HOME, { state: { noProject: true } });
return;
}
setLoading(false);
};
restoreProject().then((r) => r);
}, [dispatch, projectId, navigate]);
return loading;
}
|