use QueuedCards

This commit is contained in:
Luc Mcgrady 2025-10-04 22:52:47 +01:00
parent 8bf232ed79
commit f49d7d5fd7
No known key found for this signature in database
GPG key ID: 4F3D7A0B17CC3D9C
3 changed files with 9 additions and 8 deletions

View file

@ -297,12 +297,10 @@ message NextCardDataResponse {
} }
message NextCardData { message NextCardData {
int64 card_id = 1; QueuedCards queue = 1;
string front = 2; string front = 2;
string back = 3; string back = 3;
repeated AnswerButton answer_buttons = 4;
SchedulingStates states = 4;
repeated AnswerButton answer_buttons = 5;
} }
optional NextCardData next_card = 1; optional NextCardData next_card = 1;

View file

@ -411,11 +411,10 @@ impl crate::services::SchedulerService for Collection {
Ok(NextCardDataResponse { Ok(NextCardDataResponse {
next_card: Some(NextCardData { next_card: Some(NextCardData {
card_id: cid.0, queue: Some(queue.into()),
front: [style.clone(), render.question().to_string()].concat(), front: [style.clone(), render.question().to_string()].concat(),
back: [style, render.answer().to_string()].concat(), back: [style, render.answer().to_string()].concat(),
states: Some(next_card.states.clone().into()),
answer_buttons, answer_buttons,
}), }),
}) })

View file

@ -45,13 +45,17 @@ export class ReviewerState {
this.beginAnsweringMs = Date.now(); this.beginAnsweringMs = Date.now();
} }
get currentCard() {
return this.cardData?.queue?.cards[0];
}
public showAnswer() { public showAnswer() {
this.answerShown.set(true); this.answerShown.set(true);
this.updateHtml(this.cardData?.back || ""); this.updateHtml(this.cardData?.back || "");
} }
public easeButtonPressed(rating: number) { public easeButtonPressed(rating: number) {
const states = this.cardData!.states!; const states = this.currentCard!.states!;
const newState = [ const newState = [
states.again!, states.again!,
@ -65,7 +69,7 @@ export class ReviewerState {
rating: rating, rating: rating,
currentState: states!.current!, currentState: states!.current!,
newState, newState,
cardId: this.cardData!.cardId, cardId: this.currentCard?.card?.id,
answeredAtMillis: BigInt(Date.now()), answeredAtMillis: BigInt(Date.now()),
millisecondsTaken: Date.now() - this.beginAnsweringMs, millisecondsTaken: Date.now() - this.beginAnsweringMs,
}), }),