fix default local platform and remote workspace paths
This commit is contained in:
@@ -3927,6 +3927,7 @@ function LocalPcWorkspaceMockup({
|
||||
export default function App(): React.JSX.Element {
|
||||
const restoredStudioSessionRef = useRef<StudioRuntimeSessionState | null>(readStudioRuntimeSessionState())
|
||||
const previousWeekStateRef = useRef<Record<number, CurriculumWeek['state']>>({})
|
||||
const curriculumLoadRequestRef = useRef(0)
|
||||
const controlExpiryHandledRef = useRef<Set<string>>(new Set())
|
||||
const stopRunningWorkspaceModulesRef = useRef<(() => Promise<void>) | null>(null)
|
||||
const getRunningWorkspaceModuleNamesRef = useRef<(() => string[]) | null>(null)
|
||||
@@ -4386,10 +4387,12 @@ export default function App(): React.JSX.Element {
|
||||
const loadCurriculum = useCallback(async (): Promise<void> => {
|
||||
if (!authReady || !studentCoursesLoaded || courseSelectionVisible || !selectedCourseId) return
|
||||
|
||||
const requestId = ++curriculumLoadRequestRef.current
|
||||
const curriculumLoadingStartedAt = Date.now()
|
||||
setCurriculumLoading(true)
|
||||
try {
|
||||
const payload = await fetchCurriculum(fetchWithFreshAuth, selectedCourseId)
|
||||
if (requestId !== curriculumLoadRequestRef.current) return
|
||||
const nextWeeks = payload?.weeks ?? []
|
||||
const serverActiveWeek = payload?.activeWeek ?? null
|
||||
const previousWeekStates = previousWeekStateRef.current
|
||||
@@ -4407,7 +4410,7 @@ export default function App(): React.JSX.Element {
|
||||
setCompletedCurriculumNotice(newlyCompletedWeek)
|
||||
}
|
||||
previousWeekStateRef.current = Object.fromEntries(nextWeeks.map((week) => [week.week, week.state]))
|
||||
setCourseKey(payload?.course?.id ?? payload?.course?.slug ?? 'default-course')
|
||||
setCourseKey(selectedCourseId)
|
||||
setStudentGroup(payload?.studentGroup ?? null)
|
||||
setCurriculumWeeks(nextWeeks)
|
||||
setActiveLearningStep(payload?.activeLearningStep ?? null)
|
||||
@@ -4425,6 +4428,7 @@ export default function App(): React.JSX.Element {
|
||||
})
|
||||
setSelectedWeekState(nextSelectedWeek)
|
||||
} catch {
|
||||
if (requestId !== curriculumLoadRequestRef.current) return
|
||||
setCurriculumWeeks([])
|
||||
setCourseKey('default-course')
|
||||
setLearningStats([])
|
||||
@@ -4432,6 +4436,7 @@ export default function App(): React.JSX.Element {
|
||||
setStudentGroup(null)
|
||||
setSelectedWeekState(null)
|
||||
} finally {
|
||||
if (requestId !== curriculumLoadRequestRef.current) return
|
||||
const remainingMs = Math.max(0, 500 - (Date.now() - curriculumLoadingStartedAt))
|
||||
if (remainingMs) await new Promise<void>((resolve) => window.setTimeout(resolve, remainingMs))
|
||||
setCurriculumLoading(false)
|
||||
@@ -4813,6 +4818,7 @@ export default function App(): React.JSX.Element {
|
||||
return
|
||||
}
|
||||
if (selectedCourseStorageKey) window.localStorage.setItem(selectedCourseStorageKey, courseId)
|
||||
setCourseKey(courseId)
|
||||
setSelectedCourseId(courseId)
|
||||
setCourseSelectionVisible(false)
|
||||
setLocalPcLayoutOpen(false)
|
||||
@@ -5637,7 +5643,7 @@ export default function App(): React.JSX.Element {
|
||||
{studioEntered && workspaceWeekState && workspacePlatform && (
|
||||
<div className={localPcLayoutOpen ? 'h-full' : 'hidden h-full'}>
|
||||
<LocalPcWorkspaceMockup
|
||||
key={workspacePlatform?.id ?? 'local-pc-workspace'}
|
||||
key={`${workspacePlatform?.id ?? 'local-pc-workspace'}:${courseKey}:${workspaceWeek.week}`}
|
||||
onClose={() => {
|
||||
closeLocalPcWorkspace()
|
||||
setOuterView('curriculum')
|
||||
|
||||
@@ -39,13 +39,10 @@ export function makeTeamWeekWorkspaceRoot(workspaceRoot: string, groupId: string
|
||||
return `${normalizedRoot}/${suffix}`
|
||||
}
|
||||
|
||||
export function makePlatformWorkspaceRoot(workspaceRoot: string, studentSlug: string, courseKey: string, weekNumber: number, platformKey: string, teamGroupId?: string | null): string {
|
||||
export function makePlatformWorkspaceRoot(workspaceRoot: string, studentSlug: string, courseKey: string, weekNumber: number, _platformKey: string, teamGroupId?: string | null): string {
|
||||
const normalizedRoot = (workspaceRoot || defaultStudioSourceSettings.workspaceRoot).replace(/\/+$/, '')
|
||||
if (teamGroupId) return makeTeamWeekWorkspaceRoot(normalizedRoot, teamGroupId, courseKey, weekNumber)
|
||||
if (platformKey === 'futuredrive-local-pc') return makeWeekWorkspaceRoot(normalizedRoot, studentSlug, courseKey, weekNumber)
|
||||
const suffix = `${normalizeCoursePathSegment(courseKey)}/week-${weekNumber}`
|
||||
if (normalizedRoot === suffix || normalizedRoot.endsWith(`/${suffix}`)) return normalizedRoot
|
||||
return `${normalizedRoot}/${suffix}`
|
||||
return makeWeekWorkspaceRoot(normalizedRoot, studentSlug, courseKey, weekNumber)
|
||||
}
|
||||
|
||||
export function normalizeStudioSourceSettings(settings?: Partial<StudioSourceSettings> | null): StudioSourceSettings {
|
||||
|
||||
Reference in New Issue
Block a user