diff --git a/proto/anki/scheduler.proto b/proto/anki/scheduler.proto index 14f5b184d..3588c4117 100644 --- a/proto/anki/scheduler.proto +++ b/proto/anki/scheduler.proto @@ -305,17 +305,18 @@ message NextCardDataResponse { string back = 4; string css = 5; string body_class = 6; + bool autoplay = 7; - repeated card_rendering.AVTag question_av_tags = 7; - repeated card_rendering.AVTag answer_av_tags = 8; + repeated card_rendering.AVTag question_av_tags = 8; + repeated card_rendering.AVTag answer_av_tags = 9; // TODO: We can probably make this a little faster by using oneof and // preventing the partial_front and back being sent to svelte where it isn't // used. Alternatively we can use a completely different message for both // Rust -> Python and the Python -> Svelte though this would be more // complicated to implement. - repeated card_rendering.RenderedTemplateNode partial_front = 9; - repeated card_rendering.RenderedTemplateNode partial_back = 10; + repeated card_rendering.RenderedTemplateNode partial_front = 10; + repeated card_rendering.RenderedTemplateNode partial_back = 11; } optional NextCardData next_card = 1; diff --git a/rslib/src/scheduler/service/mod.rs b/rslib/src/scheduler/service/mod.rs index a49f31d4f..addbc4c87 100644 --- a/rslib/src/scheduler/service/mod.rs +++ b/rslib/src/scheduler/service/mod.rs @@ -409,22 +409,25 @@ impl crate::services::SchedulerService for Collection { }) .collect(); + let config = self.deck_config_for_card(&next_card.card)?; + Ok(NextCardDataResponse { next_card: Some(NextCardData { queue: Some(queue.into()), css: render.css.clone(), + partial_front: rendered_nodes_to_proto(render.qnodes), + partial_back: rendered_nodes_to_proto(render.anodes), + + answer_buttons, + autoplay: !config.inner.disable_autoplay, + // Filled by python front: "".to_string(), back: "".to_string(), body_class: "".to_string(), question_av_tags: vec![], answer_av_tags: vec![], - - partial_front: rendered_nodes_to_proto(render.qnodes), - partial_back: rendered_nodes_to_proto(render.anodes), - - answer_buttons, }), }) } else { diff --git a/ts/routes/reviewer/reviewer.ts b/ts/routes/reviewer/reviewer.ts index cee3b2038..cac8429fd 100644 --- a/ts/routes/reviewer/reviewer.ts +++ b/ts/routes/reviewer/reviewer.ts @@ -110,7 +110,9 @@ export class ReviewerState { const question = resp.nextCard?.front || ""; this.updateHtml(question, resp?.nextCard?.css, resp?.nextCard?.bodyClass); - playAvtags({ tags: this._cardData!.questionAvTags }); + if (this._cardData?.autoplay) { + playAvtags({ tags: this._cardData!.questionAvTags }); + } this.beginAnsweringMs = Date.now(); } @@ -121,7 +123,9 @@ export class ReviewerState { public showAnswer() { this.answerShown.set(true); - playAvtags({ tags: this._cardData!.answerAvTags }); + if (this._cardData?.autoplay) { + playAvtags({ tags: this._cardData!.answerAvTags }); + } this.updateHtml(this._cardData?.back || ""); }