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

@@ -6,4 +6,7 @@ SELECTION=$(rofi -dmenu <<< "$CARDS")
CARD_OUTPUT=$(/home/arthurr/code/mini_projects/scryfall_deser/target/debug/scryfall_deser --exact $SELECTION) CARD_OUTPUT=$(/home/arthurr/code/mini_projects/scryfall_deser/target/debug/scryfall_deser --exact $SELECTION)
# If you double check the first rofi selection it seems to prevent the error window from popping up
sleep 0.05
rofi -e "$CARD_OUTPUT" rofi -e "$CARD_OUTPUT"

View File

@@ -54,24 +54,24 @@ pub fn update_db_with_file(file: PathBuf) -> bool {
} }
let lowercase_name = card.name.to_lowercase(); let lowercase_name = card.name.to_lowercase();
let power_toughness = match card.power { let power_toughness = match card.power {
Some(p) => format!("{}/{}", p, card.toughness.unwrap()), Some(p) => Some(format!("{}/{}", p, card.toughness.unwrap())),
None => "".to_string(), None => None,
}; };
let oracle_text = match card.oracle_text { let oracle_text = match card.oracle_text {
Some(ot) => ot, Some(ot) => ot,
None => "".to_string(), None => "<No Oracle Text>".to_string(),
}; };
let loyalty = match card.loyalty { let loyalty = match card.loyalty {
Some(loy) => loy, Some(loy) => Some(loy),
None => "".to_string(), None => None,
}; };
let mana_cost = match card.mana_cost { let mana_cost = match card.mana_cost {
Some(mc) => mc, Some(mc) => Some(mc),
None => "".to_string(), None => None,
}; };
let res = tx.execute( 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)", "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(); tx.commit();
@@ -86,10 +86,20 @@ impl fmt::Display for DbCard {
Some(mc) => writeln!(f, "{}\t{}", self.name, mc)?, Some(mc) => writeln!(f, "{}\t{}", self.name, mc)?,
None => writeln!(f, "{}", self.name)?, None => writeln!(f, "{}", self.name)?,
} }
writeln!(f, "{}", self.type_line)?;
match &self.oracle_text { match &self.oracle_text {
Some(ot) => writeln!(f, "{}", ot)?, Some(ot) => writeln!(f, "{}", ot)?,
None => (), 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(()) Ok(())
} }
} }