Improved Null in db

Fixed the rofi error window from instantly being removed with
a double click - there's probably a better way like using some
IGNORE_FIRST_CLICK_FOR_10ms or something
This commit is contained in:
2025-08-19 23:21:42 +01:00
parent bcf68c8332
commit b6664492fa
2 changed files with 21 additions and 8 deletions

View File

@@ -54,24 +54,24 @@ pub fn update_db_with_file(file: PathBuf) -> bool {
}
let lowercase_name = card.name.to_lowercase();
let power_toughness = match card.power {
Some(p) => format!("{}/{}", p, card.toughness.unwrap()),
None => "".to_string(),
Some(p) => Some(format!("{}/{}", p, card.toughness.unwrap())),
None => None,
};
let oracle_text = match card.oracle_text {
Some(ot) => ot,
None => "".to_string(),
None => "<No Oracle Text>".to_string(),
};
let loyalty = match card.loyalty {
Some(loy) => loy,
None => "".to_string(),
Some(loy) => Some(loy),
None => None,
};
let mana_cost = match card.mana_cost {
Some(mc) => mc,
None => "".to_string(),
Some(mc) => Some(mc),
None => None,
};
let res = tx.execute(
"INSERT INTO cards (name, lowercase_name, type_line, oracle_text, power_toughness, loyalty, mana_cost, scryfall_uri) VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8)",
[card.name, lowercase_name, card.type_line, oracle_text, power_toughness, loyalty, mana_cost, card.scryfall_uri],
rusqlite::params![card.name, lowercase_name, card.type_line, oracle_text, power_toughness, loyalty, mana_cost, card.scryfall_uri],
);
}
tx.commit();
@@ -86,10 +86,20 @@ impl fmt::Display for DbCard {
Some(mc) => writeln!(f, "{}\t{}", self.name, mc)?,
None => writeln!(f, "{}", self.name)?,
}
writeln!(f, "{}", self.type_line)?;
match &self.oracle_text {
Some(ot) => writeln!(f, "{}", ot)?,
None => (),
}
match &self.power_toughness {
Some(pt) => writeln!(f, "{}", pt)?,
None => (),
}
match &self.loyalty {
Some(l) => writeln!(f, "Starting Loyalty: {}", l)?,
None => (),
}
writeln!(f, "{}", self.scryfall_uri)?;
Ok(())
}
}