fixed the rest of the clippy warnings; bumped version to 0.10.0

This commit is contained in:
Thomas Eppers 2021-10-23 13:26:09 +02:00
parent a718f6f8fb
commit 45f2bb64b0
5 changed files with 21 additions and 12 deletions

2
Cargo.lock generated
View File

@ -673,7 +673,7 @@ dependencies = [
[[package]]
name = "reel-moby"
version = "0.9.0"
version = "0.10.0"
dependencies = [
"chrono",
"lazy_static",

View File

@ -1,7 +1,7 @@
[package]
name = "reel-moby"
version = "0.9.0"
version = "0.10.0"
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View File

@ -102,7 +102,6 @@ impl Ui {
Ok(Key::Ctrl('q')) => break 'core, //quit program without saving
Ok(Key::Char('\t')) => {
ui.state.next();
()
}
Ok(Key::Ctrl('s')) => match ui.services.save() {
Err(e) => {

View File

@ -107,10 +107,7 @@ impl NoYaml {
ui.repo.confirm();
ui.tags = tag_list::TagList::with_repo_name(ui.repo.get());
}
State::SelectTag => {
ui.tags.get_selected();
()
}
State::SelectTag => ui.tags.handle_input(Key::Char('\n')),
},
Ok(Key::Char(key)) => match ui.state {
State::EditRepo => {

View File

@ -25,6 +25,7 @@ impl fmt::Display for Error {
enum Line {
Status(String),
Image(tags::Images),
NextPage(String),
}
impl fmt::Display for Line {
@ -32,6 +33,7 @@ impl fmt::Display for Line {
match self {
Line::Status(s) => write!(f, "{}", s),
Line::Image(i) => write!(f, "{}", i),
Line::NextPage(s) => write!(f, "{}", s),
}
}
}
@ -68,7 +70,7 @@ impl TagList {
match tags.next_page() {
Err(_) => (),
Ok(new_tags) => {
lines.push(Line::Status(String::from("load more tags")));
lines.push(Line::NextPage(String::from("load more tags")));
tags = new_tags;
}
};
@ -115,24 +117,35 @@ impl TagList {
match key {
Key::Down => self.next(),
Key::Up => self.previous(),
Key::Char('\n') => self.select(),
_ => (),
}
}
/// loads new tags when matching line is selected
fn select(&mut self) {
if let Some(i) = self.state.selected() {
if let Line::NextPage(_) = &self.lines[i] {
self.load_next_page()
}
}
}
pub fn get_selected(&mut self) -> Result<String, Error> {
match self.state.selected() {
None => Err(Error::NoneSelected),
Some(i) if i == self.lines.len() - 1 => {
self.load_next_page();
Err(Error::NextPageSelected)
}
Some(i) => match &self.lines[i] {
Line::Status(_) => Err(Error::SelectedStatus),
Line::Image(i) => Ok(i.tag_name.clone()),
Line::NextPage(_) => {
self.load_next_page();
Err(Error::NextPageSelected)
}
},
}
}
/// load new tags from the next page
fn load_next_page(&mut self) {
match &self.tags {
Some(tags) => match tags.next_page() {