()
| 49 | setLoadedProjectName(""); |
| 50 | |
| 51 | const load = async () => { |
| 52 | await Promise.all([loadCurrentUser(), loadServerInfo()]); |
| 53 | const nextProject = await fetchProject(projectName); |
| 54 | if (stale) return; |
| 55 | if (!nextProject) { |
| 56 | // Project missing or not accessible (e.g. no `bb.projects.get`): drop |
| 57 | // it from recent visits and bounce to landing, like ProjectRouteShell. |
| 58 | const projectRoute = navigateRef.current.resolve({ |
| 59 | name: PROJECT_V1_ROUTE_DETAIL, |
| 60 | params: { projectId }, |
| 61 | }); |
| 62 | removeRecentVisit(projectRoute.fullPath); |
| 63 | const error = useAppStore.getState().projectErrorsByName[projectName]; |
| 64 | if (error) { |
| 65 | notify({ |
| 66 | module: "bytebase", |
| 67 | style: "CRITICAL", |
| 68 | title: `Failed to fetch project ${projectId}`, |
| 69 | description: error.message, |
| 70 | }); |
| 71 | } |
| 72 | void navigateRef.current.replace({ name: WORKSPACE_ROUTE_LANDING }); |
| 73 | return; |
| 74 | } |
| 75 | setRecentProject(nextProject.name); |
| 76 | if (!stale) { |
| 77 | setLoadedProjectName(projectName); |
| 78 | } |
| 79 | }; |
| 80 | |
| 81 | void load(); |
| 82 | return () => { |
no test coverage detected