Skip to content

Commit 822057b

Browse files
committed
pass filterFcns, await initial hydration lookup
1 parent 745cfc8 commit 822057b

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

packages/db/src/study/SessionController.ts

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ export class SessionController extends Loggable {
103103
private failedQ: ItemQueue<StudySessionFailedItem> = new ItemQueue<StudySessionFailedItem>();
104104
private hydratedQ: ItemQueue<HydratedCard> = new ItemQueue<HydratedCard>();
105105
private _currentCard: StudySessionItem | null = null;
106-
107106

108107
private startTime: Date;
109108
private endTime: Date;
@@ -200,9 +199,7 @@ export class SessionController extends Loggable {
200199
this.error('Error preparing study session:', e);
201200
}
202201

203-
204-
205-
void this._fillHydratedQueue();
202+
await this._fillHydratedQueue();
206203

207204
this._intervalHandle = setInterval(() => {
208205
this.tick();
@@ -255,9 +252,9 @@ export class SessionController extends Loggable {
255252
this.log(report);
256253
}
257254

258-
private async getNewCards(n: number = 10) {
255+
private async getNewCards(n: number = 10, filter?: (c: string) => boolean) {
259256
const perCourse = Math.ceil(n / this.sources.length);
260-
const newContent = await Promise.all(this.sources.map((c) => c.getNewCards(perCourse)));
257+
const newContent = await Promise.all(this.sources.map((c) => c.getNewCards(perCourse, filter)));
261258

262259
// [ ] is this a noop?
263260
newContent.forEach((newContentFromSource) => {
@@ -278,12 +275,13 @@ export class SessionController extends Loggable {
278275
}
279276
}
280277

281-
282-
283-
private _selectNextItemToHydrate(action: | 'dismiss-success'
284-
| 'dismiss-failed'
285-
| 'marked-failed'
286-
| 'dismiss-error' = 'dismiss-success'): StudySessionItem | null {
278+
private _selectNextItemToHydrate(
279+
action:
280+
| 'dismiss-success'
281+
| 'dismiss-failed'
282+
| 'marked-failed'
283+
| 'dismiss-error' = 'dismiss-success'
284+
): StudySessionItem | null {
287285
const choice = Math.random();
288286
let newBound: number = 0.1;
289287
let reviewBound: number = 0.75;
@@ -353,7 +351,6 @@ export class SessionController extends Loggable {
353351
}
354352

355353
public nextCard(
356-
// [ ] this is often slow. Why?
357354
action:
358355
| 'dismiss-success'
359356
| 'dismiss-failed'

0 commit comments

Comments
 (0)