aboutsummaryrefslogtreecommitdiff
path: root/src/gui/question.rs
diff options
context:
space:
mode:
authorJoris2022-11-27 15:38:39 +0100
committerJoris2022-11-27 15:38:39 +0100
commitd3fb69cf129fe70c932a5d82fdd1bcc613544b5b (patch)
tree6a098c7900f96791489b8548979fb71ccea03e59 /src/gui/question.rs
parent765ba94cdd65184bd4b443c3a946d0d96dc805d6 (diff)
downloadflashcards-d3fb69cf129fe70c932a5d82fdd1bcc613544b5b.tar.gz
flashcards-d3fb69cf129fe70c932a5d82fdd1bcc613544b5b.tar.bz2
flashcards-d3fb69cf129fe70c932a5d82fdd1bcc613544b5b.zip
Speed up deck synchronization
Apply changes for what has been inserted, updated, removed. Also use transactions to speed up multi-writing.
Diffstat (limited to 'src/gui/question.rs')
-rw-r--r--src/gui/question.rs10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/gui/question.rs b/src/gui/question.rs
index 71c3ea2..2aa6e65 100644
--- a/src/gui/question.rs
+++ b/src/gui/question.rs
@@ -1,6 +1,6 @@
use crate::{
gui::util,
- model::{card::Card, difficulty, difficulty::Difficulty},
+ model::{difficulty, difficulty::Difficulty, Card},
util::event::{Event, Events},
util::serialization,
};
@@ -150,7 +150,9 @@ pub fn ask<B: Backend>(
Key::Char(c) => {
state.input.push(c);
if is_correct(&state.input, &card.responses) {
- state.answer = Answer::Difficulty { difficulty: Difficulty::Good }
+ state.answer = Answer::Difficulty {
+ difficulty: Difficulty::Good,
+ }
}
}
Key::Backspace => {
@@ -161,12 +163,12 @@ pub fn ask<B: Backend>(
}
Key::Ctrl('w') => {
let mut words = state.input.split_whitespace().collect::<Vec<&str>>();
- if words.len() > 0 {
+ if !words.is_empty() {
words.truncate(words.len() - 1);
state.input = format!(
"{}{}",
words.join(" "),
- if words.len() > 0 { " " } else { "" }
+ if !words.is_empty() { " " } else { "" }
);
}
}