Skip to content

Commit b9892ac

Browse files
committed
Recognize requireAll
1 parent 2370447 commit b9892ac

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/unit.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ export async function handleUnit(
1313
state: State,
1414
id: string,
1515
name: string,
16-
lessons: Record<string, { next: string[]; requires: string[] }>,
16+
lessons: Record<
17+
string,
18+
{ next: string[]; requires: string[]; requireAll?: boolean }
19+
>,
1720
): Promise<void> {
1821
// First, we need to figure out what the actual ID of our unit is.
1922
// If there isn't one, we'll just set it to null.
@@ -38,7 +41,10 @@ export async function handleUnit(
3841
await delay(state);
3942

4043
// Next, we need to go through the lessons and map from friendly names to ids.
41-
const map: Record<string, { next: string[]; requires: string[] }> = {};
44+
const map: Record<
45+
string,
46+
{ next: string[]; requires: string[]; requireAll: boolean }
47+
> = {};
4248

4349
for (const key in lessons) {
4450
// Map the key.
@@ -64,7 +70,11 @@ export async function handleUnit(
6470
newRequires.push(await mapKey(item, state));
6571
}
6672

67-
map[newKey] = { next: newNext, requires: newRequires };
73+
map[newKey] = {
74+
next: newNext,
75+
requires: newRequires,
76+
requireAll: Boolean(lessons[key].requireAll),
77+
};
6878
}
6979

7080
// Create or update the unit.

0 commit comments

Comments
 (0)