Skip to content

Commit

Permalink
Use new RelayUrl.domain() instead of function in Relay struct
Browse files Browse the repository at this point in the history
  • Loading branch information
mikedilger committed Sep 7, 2023
1 parent 46f2c53 commit 7b33619
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 16 deletions.
12 changes: 0 additions & 12 deletions src/relay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,3 @@ impl Relay {
Ok(None)
}
}

/**
* Static helper functions
*/
impl Relay {
pub fn domain_from_relay_url(relay: &RelayUrl) -> &str /* domain */ {
let domain = relay.0.trim_start_matches("wss://");
let domain = domain.trim_start_matches("ws://");
let domain = domain.trim_end_matches('/');
domain
}
}
3 changes: 1 addition & 2 deletions src/ui/relays/coverage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use nostr_types::{PublicKey, RelayUrl};
use crate::{
comms::ToOverlordMessage,
globals::GLOBALS,
relay::Relay,
ui::{
widgets::{
self,
Expand Down Expand Up @@ -107,7 +106,7 @@ impl<'a> CoverageEntry<'a> {
let relays_string = self
.relays
.iter()
.map(|rurl| Relay::domain_from_relay_url(rurl).to_string())
.map(|rurl| rurl.domain())
.collect::<Vec<String>>()
.join(", ");
draw_text_at(ui, pos, relays_string.into(), Align::LEFT, None, None);
Expand Down
4 changes: 2 additions & 2 deletions src/ui/widgets/relay_entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,8 @@ impl RelayEntry {

impl RelayEntry {
fn paint_title(&self, ui: &mut Ui, rect: &Rect) {
let title = Relay::domain_from_relay_url(&self.relay.url);
let mut title = safe_truncate(title, TITLE_MAX_LEN).to_string();
let title = self.relay.url.domain();
let mut title = safe_truncate(&title, TITLE_MAX_LEN).to_string();
if self.relay.url.0.len() > TITLE_MAX_LEN {
title.push('\u{2026}'); // append ellipsis
}
Expand Down

0 comments on commit 7b33619

Please sign in to comment.