Skip to content

Commit 4f86b66

Browse files
committed
Remove hardcoded MAX_TUTORIAL_ID
1 parent b2fdf62 commit 4f86b66

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

frontend/src/lib/tutorialUtils.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,25 @@
11
import { get } from 'svelte/store'
22
import { tutorialsToDo, skippedAll } from './stores'
33
import { UserService } from './gen'
4+
import { TUTORIALS_CONFIG } from './tutorials/config'
45

5-
const MAX_TUTORIAL_ID = 7
6+
/**
7+
* Get the maximum tutorial index from the config.
8+
* This ensures we don't hardcode the max ID and it automatically updates when tutorials are added.
9+
*/
10+
function getMaxTutorialId(): number {
11+
let maxId = 0
12+
for (const tab of Object.values(TUTORIALS_CONFIG)) {
13+
for (const tutorial of tab.tutorials) {
14+
if (tutorial.index !== undefined && tutorial.index > maxId) {
15+
maxId = tutorial.index
16+
}
17+
}
18+
}
19+
return maxId
20+
}
21+
22+
const MAX_TUTORIAL_ID = getMaxTutorialId()
623

724
/**
825
* Helper function to calculate tutorial progress for a given set of tutorial indexes.

0 commit comments

Comments
 (0)