Skip to content

Commit

Permalink
fix: short-circuit when no relays loaded/fetched
Browse files Browse the repository at this point in the history
  • Loading branch information
norskeld committed Mar 20, 2024
1 parent 52503da commit a101cdd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
9 changes: 7 additions & 2 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub async fn run() -> anyhow::Result<()> {
| None => Coord::fetch().await?,
};

thread::sleep(std::time::Duration::from_secs(1));
thread::sleep(Duration::from_secs(1));

// -----------------------------------------------------------------------------------------------
// 2. Load relays from file and filter them.
Expand All @@ -43,7 +43,12 @@ pub async fn run() -> anyhow::Result<()> {

let relays = loader.load()?;

thread::sleep(std::time::Duration::from_secs(1));
thread::sleep(Duration::from_secs(1));

if relays.is_empty() {
spinner.stop();
anyhow::bail!("Couldn't find any relays");
}

// -----------------------------------------------------------------------------------------------
// 3. Ping relays.
Expand Down
7 changes: 5 additions & 2 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,11 @@ impl Spinner {
}

/// Sets the message of the spinner.
pub fn set_message(&self, message: &'static str) {
self.spinner.set_message(message);
pub fn set_message<S>(&self, message: S)
where
S: Into<String> + AsRef<str>,
{
self.spinner.set_message(message.into());
}

/// Stops the spinner and clears the message.
Expand Down

0 comments on commit a101cdd

Please sign in to comment.