Fix: Respect autoplay setting

This commit is contained in:
Luc Mcgrady 2025-10-31 09:01:29 +00:00
parent d47cb1bd55
commit cf9c265570
No known key found for this signature in database
GPG key ID: 4F3D7A0B17CC3D9C
3 changed files with 19 additions and 11 deletions

View file

@ -305,17 +305,18 @@ message NextCardDataResponse {
string back = 4; string back = 4;
string css = 5; string css = 5;
string body_class = 6; string body_class = 6;
bool autoplay = 7;
repeated card_rendering.AVTag question_av_tags = 7; repeated card_rendering.AVTag question_av_tags = 8;
repeated card_rendering.AVTag answer_av_tags = 8; repeated card_rendering.AVTag answer_av_tags = 9;
// TODO: We can probably make this a little faster by using oneof and // 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 // 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 // used. Alternatively we can use a completely different message for both
// Rust -> Python and the Python -> Svelte though this would be more // Rust -> Python and the Python -> Svelte though this would be more
// complicated to implement. // complicated to implement.
repeated card_rendering.RenderedTemplateNode partial_front = 9; repeated card_rendering.RenderedTemplateNode partial_front = 10;
repeated card_rendering.RenderedTemplateNode partial_back = 10; repeated card_rendering.RenderedTemplateNode partial_back = 11;
} }
optional NextCardData next_card = 1; optional NextCardData next_card = 1;

View file

@ -409,22 +409,25 @@ impl crate::services::SchedulerService for Collection {
}) })
.collect(); .collect();
let config = self.deck_config_for_card(&next_card.card)?;
Ok(NextCardDataResponse { Ok(NextCardDataResponse {
next_card: Some(NextCardData { next_card: Some(NextCardData {
queue: Some(queue.into()), queue: Some(queue.into()),
css: render.css.clone(), 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 // Filled by python
front: "".to_string(), front: "".to_string(),
back: "".to_string(), back: "".to_string(),
body_class: "".to_string(), body_class: "".to_string(),
question_av_tags: vec![], question_av_tags: vec![],
answer_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 { } else {

View file

@ -110,7 +110,9 @@ export class ReviewerState {
const question = resp.nextCard?.front || ""; const question = resp.nextCard?.front || "";
this.updateHtml(question, resp?.nextCard?.css, resp?.nextCard?.bodyClass); 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(); this.beginAnsweringMs = Date.now();
} }
@ -121,7 +123,9 @@ export class ReviewerState {
public showAnswer() { public showAnswer() {
this.answerShown.set(true); this.answerShown.set(true);
playAvtags({ tags: this._cardData!.answerAvTags }); if (this._cardData?.autoplay) {
playAvtags({ tags: this._cardData!.answerAvTags });
}
this.updateHtml(this._cardData?.back || ""); this.updateHtml(this._cardData?.back || "");
} }