Skip to content

Commit 28e08a7

Browse files
committed
disable the undo button if there is nothing to undo
1 parent 0d0f506 commit 28e08a7

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

src/drill/get.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ const CLOZE_TAG: &str = "CLOZE_DELETION";
2828

2929
pub async fn get_handler(State(state): State<ServerState>) -> (StatusCode, Html<String>) {
3030
let mutable = state.mutable.lock().unwrap();
31+
let undo_disabled = mutable.reviewed.is_empty();
3132
let body = if mutable.finished {
3233
html! {
3334
div.finished {
@@ -115,7 +116,11 @@ pub async fn get_handler(State(state): State<ServerState>) -> (StatusCode, Html<
115116
let card_controls = if mutable.reveal {
116117
html! {
117118
form action="/" method="post" {
118-
input id="undo" type="submit" name="action" value="Undo";
119+
@if undo_disabled {
120+
input id="undo" type="submit" name="action" value="Undo" disabled;
121+
} @else {
122+
input id="undo" type="submit" name="action" value="Undo";
123+
}
119124
div.spacer {}
120125
input id="forgot" type="submit" name="action" value="Forgot";
121126
input id="hard" type="submit" name="action" value="Hard";
@@ -128,7 +133,11 @@ pub async fn get_handler(State(state): State<ServerState>) -> (StatusCode, Html<
128133
} else {
129134
html! {
130135
form action="/" method="post" {
131-
input id="undo" type="submit" name="action" value="Undo";
136+
@if undo_disabled {
137+
input id="undo" type="submit" name="action" value="Undo" disabled;
138+
} @else {
139+
input id="undo" type="submit" name="action" value="Undo";
140+
}
132141
div.spacer {}
133142
input id="reveal" type="submit" name="action" value="Reveal";
134143
div.spacer {}

0 commit comments

Comments
 (0)