This commit is contained in:
Luc Mcgrady 2025-10-04 21:13:39 +01:00
parent b6459ced18
commit 8bf232ed79
No known key found for this signature in database
GPG key ID: 4F3D7A0B17CC3D9C
3 changed files with 15 additions and 8 deletions

View file

@ -10,9 +10,13 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
export let info: NextCardDataResponse_AnswerButton; export let info: NextCardDataResponse_AnswerButton;
export let state: ReviewerState; export let state: ReviewerState;
const labels = [tr.studyingAgain(), tr.studyingHard(), tr.studyingGood(), tr.studyingEasy()] const labels = [
tr.studyingAgain(),
tr.studyingHard(),
tr.studyingGood(),
tr.studyingEasy(),
];
$: label = labels[info.rating]; $: label = labels[info.rating];
</script> </script>
<span> <span>

View file

@ -21,7 +21,6 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
const remainingIndex = writable(0); const remainingIndex = writable(0);
$: button_count = $answerShown ? $answerButtons.length : 1; $: button_count = $answerShown ? $answerButtons.length : 1;
</script> </script>
<div id="outer" class="fancy"> <div id="outer" class="fancy">

View file

@ -1,6 +1,10 @@
// Copyright: Ankitects Pty Ltd and contributors // Copyright: Ankitects Pty Ltd and contributors
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html // License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import { CardAnswer, NextCardDataResponse_AnswerButton, type NextCardDataResponse_NextCardData } from "@generated/anki/scheduler_pb"; import {
CardAnswer,
type NextCardDataResponse_AnswerButton,
type NextCardDataResponse_NextCardData,
} from "@generated/anki/scheduler_pb";
import { nextCardData } from "@generated/backend"; import { nextCardData } from "@generated/backend";
import { writable } from "svelte/store"; import { writable } from "svelte/store";
@ -10,7 +14,7 @@ export class ReviewerState {
beginAnsweringMs = Date.now(); beginAnsweringMs = Date.now();
readonly cardClass = writable(""); readonly cardClass = writable("");
readonly answerButtons = writable<NextCardDataResponse_AnswerButton[]>([]); readonly answerButtons = writable<NextCardDataResponse_AnswerButton[]>([]);
readonly answerShown = writable(false) readonly answerShown = writable(false);
iframe: HTMLIFrameElement | undefined = undefined; iframe: HTMLIFrameElement | undefined = undefined;
@ -38,7 +42,7 @@ export class ReviewerState {
const question = resp.nextCard?.front || ""; const question = resp.nextCard?.front || "";
this.answerShown.set(false); this.answerShown.set(false);
this.updateHtml(question); this.updateHtml(question);
this.beginAnsweringMs = Date.now() this.beginAnsweringMs = Date.now();
} }
public showAnswer() { public showAnswer() {
@ -49,12 +53,12 @@ export class ReviewerState {
public easeButtonPressed(rating: number) { public easeButtonPressed(rating: number) {
const states = this.cardData!.states!; const states = this.cardData!.states!;
const newState = ([ const newState = [
states.again!, states.again!,
states.hard!, states.hard!,
states.good!, states.good!,
states.easy!, states.easy!,
])[rating]!; ][rating]!;
this.showQuestion( this.showQuestion(
new CardAnswer({ new CardAnswer({