mirror of
https://github.com/aljazceru/notedeck.git
synced 2025-12-19 09:34:19 +01:00
@@ -56,10 +56,10 @@ impl ClientMessage {
|
||||
Self::Raw(raw) => raw.clone(),
|
||||
Self::Req { sub_id, filters } => {
|
||||
if filters.is_empty() {
|
||||
format!("[\"REQ\",\"{}\",{{ }}]", sub_id)
|
||||
format!("[\"REQ\",\"{sub_id}\",{{ }}]")
|
||||
} else if filters.len() == 1 {
|
||||
let filters_json_str = filters[0].json()?;
|
||||
format!("[\"REQ\",\"{}\",{}]", sub_id, filters_json_str)
|
||||
format!("[\"REQ\",\"{sub_id}\",{filters_json_str}]")
|
||||
} else {
|
||||
let filters_json_str: Result<Vec<String>, Error> = filters
|
||||
.iter()
|
||||
|
||||
@@ -46,8 +46,8 @@ impl From<RelayEvent<'_>> for OwnedRelayEvent {
|
||||
RelayEvent::Other(ws_message) => {
|
||||
let ws_str = match ws_message {
|
||||
WsMessage::Binary(_) => "Binary".to_owned(),
|
||||
WsMessage::Text(t) => format!("Text:{}", t),
|
||||
WsMessage::Unknown(u) => format!("Unknown:{}", u),
|
||||
WsMessage::Text(t) => format!("Text:{t}"),
|
||||
WsMessage::Unknown(u) => format!("Unknown:{u}"),
|
||||
WsMessage::Ping(_) => "Ping".to_owned(),
|
||||
WsMessage::Pong(_) => "Pong".to_owned(),
|
||||
};
|
||||
@@ -57,9 +57,9 @@ impl From<RelayEvent<'_>> for OwnedRelayEvent {
|
||||
RelayEvent::Message(relay_message) => {
|
||||
let relay_msg = match relay_message {
|
||||
RelayMessage::OK(_) => "OK".to_owned(),
|
||||
RelayMessage::Eose(s) => format!("EOSE:{}", s),
|
||||
RelayMessage::Event(_, s) => format!("EVENT:{}", s),
|
||||
RelayMessage::Notice(s) => format!("NOTICE:{}", s),
|
||||
RelayMessage::Eose(s) => format!("EOSE:{s}"),
|
||||
RelayMessage::Event(_, s) => format!("EVENT:{s}"),
|
||||
RelayMessage::Notice(s) => format!("NOTICE:{s}"),
|
||||
};
|
||||
OwnedRelayEvent::Message(relay_msg)
|
||||
}
|
||||
|
||||
@@ -15,9 +15,9 @@ pub fn hybrid_contacts_filter(
|
||||
add_pk: Option<&[u8; 32]>,
|
||||
with_hashtags: bool,
|
||||
) -> Result<HybridFilter, Error> {
|
||||
let local = filter::filter_from_tags(¬e, add_pk, with_hashtags)?
|
||||
let local = filter::filter_from_tags(note, add_pk, with_hashtags)?
|
||||
.into_filter([1], filter::default_limit());
|
||||
let remote = filter::filter_from_tags(¬e, add_pk, with_hashtags)?
|
||||
let remote = filter::filter_from_tags(note, add_pk, with_hashtags)?
|
||||
.into_filter([1, 0], filter::default_remote_limit());
|
||||
|
||||
Ok(HybridFilter::split(local, remote))
|
||||
|
||||
@@ -235,7 +235,7 @@ impl HybridFilter {
|
||||
Self::Split(split) => &split.local,
|
||||
|
||||
// local as the same as remote in unsplit
|
||||
Self::Unsplit(local) => &local,
|
||||
Self::Unsplit(local) => local,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -163,11 +163,11 @@ const KB: usize = 1024;
|
||||
fn byte_to_string(b: usize) -> String {
|
||||
if b >= MB {
|
||||
let mbs = b as f32 / MB as f32;
|
||||
format!("{:.2} MB", mbs)
|
||||
format!("{mbs:.2} MB")
|
||||
} else if b >= KB {
|
||||
let kbs = b as f32 / KB as f32;
|
||||
format!("{:.2} KB", kbs)
|
||||
format!("{kbs:.2} KB")
|
||||
} else {
|
||||
format!("{} B", b)
|
||||
format!("{b} B")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ impl fmt::Display for RelaySpec {
|
||||
// add the read and write markers if present
|
||||
impl fmt::Debug for RelaySpec {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "\"{}\"", self)?;
|
||||
write!(f, "\"{self}\"")?;
|
||||
if self.has_read_marker {
|
||||
write!(f, " [r]")?;
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ impl Directory {
|
||||
} else {
|
||||
Err(Error::Io(io::Error::new(
|
||||
io::ErrorKind::NotFound,
|
||||
format!("Requested file was not found: {}", file_name),
|
||||
format!("Requested file was not found: {file_name}"),
|
||||
)))
|
||||
}
|
||||
}
|
||||
@@ -142,8 +142,7 @@ impl Directory {
|
||||
})
|
||||
} else {
|
||||
Err(Error::Generic(format!(
|
||||
"Requested file was not found: {}",
|
||||
file_name
|
||||
"Requested file was not found: {file_name}"
|
||||
)))
|
||||
}
|
||||
}
|
||||
@@ -197,8 +196,7 @@ pub fn delete_file(directory: &Path, file_name: String) -> Result<()> {
|
||||
fs::remove_file(file_to_delete).map_err(Error::Io)
|
||||
} else {
|
||||
Err(Error::Generic(format!(
|
||||
"Requested file to delete was not found: {}",
|
||||
file_name
|
||||
"Requested file to delete was not found: {file_name}"
|
||||
)))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,37 +18,37 @@ pub fn time_ago_since(timestamp: u64) -> String {
|
||||
|
||||
let years = duration / 31_536_000; // seconds in a year
|
||||
if years >= 1 {
|
||||
return format!("{}{}yr", relstr, years);
|
||||
return format!("{relstr}{years}yr");
|
||||
}
|
||||
|
||||
let months = duration / 2_592_000; // seconds in a month (30.44 days)
|
||||
if months >= 1 {
|
||||
return format!("{}{}mth", relstr, months);
|
||||
return format!("{relstr}{months}mth");
|
||||
}
|
||||
|
||||
let weeks = duration / 604_800; // seconds in a week
|
||||
if weeks >= 1 {
|
||||
return format!("{}{}wk", relstr, weeks);
|
||||
return format!("{relstr}{weeks}wk");
|
||||
}
|
||||
|
||||
let days = duration / 86_400; // seconds in a day
|
||||
if days >= 1 {
|
||||
return format!("{}{}d", relstr, days);
|
||||
return format!("{relstr}{days}d");
|
||||
}
|
||||
|
||||
let hours = duration / 3600; // seconds in an hour
|
||||
if hours >= 1 {
|
||||
return format!("{}{}h", relstr, hours);
|
||||
return format!("{relstr}{hours}h");
|
||||
}
|
||||
|
||||
let minutes = duration / 60; // seconds in a minute
|
||||
if minutes >= 1 {
|
||||
return format!("{}{}m", relstr, minutes);
|
||||
return format!("{relstr}{minutes}m");
|
||||
}
|
||||
|
||||
let seconds = duration;
|
||||
if seconds >= 3 {
|
||||
return format!("{}{}s", relstr, seconds);
|
||||
return format!("{relstr}{seconds}s");
|
||||
}
|
||||
|
||||
"now".to_string()
|
||||
|
||||
@@ -467,15 +467,15 @@ pub enum ZappingError {
|
||||
impl std::fmt::Display for ZappingError {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
ZappingError::InvoiceFetchFailed(err) => write!(f, "Failed to fetch invoice: {}", err),
|
||||
ZappingError::InvoiceFetchFailed(err) => write!(f, "Failed to fetch invoice: {err}"),
|
||||
ZappingError::InvalidAccount => write!(f, "Invalid account"),
|
||||
ZappingError::UnsupportedOperation => {
|
||||
write!(f, "Unsupported operation (e.g. profile zaps)")
|
||||
}
|
||||
ZappingError::InvalidZapAddress => write!(f, "Invalid zap address"),
|
||||
ZappingError::SenderNoWallet => write!(f, "Sender has no wallet"),
|
||||
ZappingError::InvalidNWCResponse(msg) => write!(f, "Invalid NWC response: {}", msg),
|
||||
ZappingError::FutureError(msg) => write!(f, "Future error: {}", msg),
|
||||
ZappingError::InvalidNWCResponse(msg) => write!(f, "Invalid NWC response: {msg}"),
|
||||
ZappingError::FutureError(msg) => write!(f, "Future error: {msg}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,8 +106,7 @@ async fn main() {
|
||||
.collect();
|
||||
assert!(
|
||||
completely_unrecognized.is_empty(),
|
||||
"unrecognized args: {:?}",
|
||||
completely_unrecognized
|
||||
"unrecognized args: {completely_unrecognized:?}"
|
||||
);
|
||||
|
||||
chrome.add_app(NotedeckApp::Columns(columns));
|
||||
|
||||
@@ -6,7 +6,7 @@ fn fallback() {
|
||||
.ok()
|
||||
.and_then(|cwd| cwd.file_name().and_then(|fname| fname.to_str()))
|
||||
{
|
||||
println!("cargo:rustc-env=GIT_COMMIT_HASH={}", dirname);
|
||||
println!("cargo:rustc-env=GIT_COMMIT_HASH={dirname}");
|
||||
} else {
|
||||
println!("cargo:rustc-env=GIT_COMMIT_HASH=unknown");
|
||||
}
|
||||
|
||||
@@ -504,7 +504,7 @@ impl Damus {
|
||||
|
||||
pub fn gen_subid(&self, kind: &SubKind) -> String {
|
||||
if self.options.contains(AppOptions::Debug) {
|
||||
format!("{:?}", kind)
|
||||
format!("{kind:?}")
|
||||
} else {
|
||||
Uuid::new_v4().to_string()
|
||||
}
|
||||
|
||||
@@ -55,8 +55,7 @@ fn available_characters(ui: &egui::Ui, family: egui::FontFamily) -> Vec<char> {
|
||||
.fonts
|
||||
.font(&egui::FontId::new(10.0, family)) // size is arbitrary for getting the characters
|
||||
.characters()
|
||||
.iter()
|
||||
.map(|(chr, _v)| chr)
|
||||
.keys()
|
||||
.filter(|chr| !chr.is_whitespace() && !chr.is_ascii_control())
|
||||
.copied()
|
||||
.collect()
|
||||
|
||||
@@ -270,7 +270,7 @@ impl Decks {
|
||||
if self.decks.len() > 1 {
|
||||
self.decks.remove(index);
|
||||
|
||||
let info_prefix = format!("Removed deck at index {}", index);
|
||||
let info_prefix = format!("Removed deck at index {index}");
|
||||
match index.cmp(&self.active_deck) {
|
||||
std::cmp::Ordering::Less => {
|
||||
info!(
|
||||
|
||||
@@ -106,7 +106,7 @@ fn create_nip96_request(
|
||||
)
|
||||
.into_bytes();
|
||||
body.extend(file_contents);
|
||||
body.extend(format!("\r\n--{}--\r\n", boundary).as_bytes());
|
||||
body.extend(format!("\r\n--{boundary}--\r\n").as_bytes());
|
||||
|
||||
let headers = ehttp::Headers::new(&[
|
||||
(
|
||||
@@ -246,7 +246,7 @@ impl MediaPath {
|
||||
let file_name = path
|
||||
.file_name()
|
||||
.and_then(|name| name.to_str())
|
||||
.unwrap_or(&format!("file.{}", ex))
|
||||
.unwrap_or(&format!("file.{ex}"))
|
||||
.to_owned();
|
||||
|
||||
Ok(MediaPath {
|
||||
@@ -256,8 +256,7 @@ impl MediaPath {
|
||||
})
|
||||
} else {
|
||||
Err(Error::Generic(format!(
|
||||
"{:?} does not have an extension",
|
||||
path
|
||||
"{path:?} does not have an extension"
|
||||
)))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -192,7 +192,7 @@ impl fmt::Display for MetadataKeyword {
|
||||
.find(|(_, keyword)| keyword == self)
|
||||
.map(|(name, _)| *name)
|
||||
{
|
||||
write!(f, "{}", name)
|
||||
write!(f, "{name}")
|
||||
} else {
|
||||
write!(f, "UnknownMetadataKeyword")
|
||||
}
|
||||
|
||||
@@ -83,8 +83,7 @@ fn get_log_str(interactor: &Directory) -> Option<String> {
|
||||
|
||||
fn get_prefix(file_name: &str, lines_displayed: usize, num_total_lines: usize) -> String {
|
||||
format!(
|
||||
"===\nDisplaying the last {} of {} lines in file {}\n===\n\n",
|
||||
lines_displayed, num_total_lines, file_name,
|
||||
"===\nDisplaying the last {lines_displayed} of {num_total_lines} lines in file {file_name}\n===\n\n",
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -734,7 +734,7 @@ pub fn is_timeline_ready(
|
||||
let note = ndb.get_note_by_key(&txn, note_key).expect("note");
|
||||
let add_pk = timeline.kind.pubkey().map(|pk| pk.bytes());
|
||||
|
||||
hybrid_contacts_filter(¬e, add_pk, with_hashtags).map_err(Into::into)
|
||||
hybrid_contacts_filter(¬e, add_pk, with_hashtags)
|
||||
};
|
||||
|
||||
// TODO: into_follow_filter is hardcoded to contact lists, let's generalize
|
||||
|
||||
@@ -679,7 +679,7 @@ pub fn render_add_column_routes(
|
||||
|
||||
// TODO: spin off the list search here instead
|
||||
|
||||
ui.label(format!("error: could not find {:?}", list_kind));
|
||||
ui.label(format!("error: could not find {list_kind:?}"));
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -139,7 +139,7 @@ fn show_warnings(ui: &mut Ui, warn_no_icon: bool, warn_no_title: bool) {
|
||||
|
||||
ui.add(
|
||||
egui::Label::new(
|
||||
RichText::new(format!("Please {}.", message)).color(ui.visuals().error_fg_color),
|
||||
RichText::new(format!("Please {message}.")).color(ui.visuals().error_fg_color),
|
||||
)
|
||||
.wrap(),
|
||||
);
|
||||
|
||||
@@ -121,12 +121,9 @@ impl<'a> EditProfileView<'a> {
|
||||
ui.colored_label(
|
||||
ui.visuals().noninteractive().fg_stroke.color,
|
||||
RichText::new(if use_domain {
|
||||
format!("\"{}\" will be used for identification", suffix)
|
||||
format!("\"{suffix}\" will be used for identification")
|
||||
} else {
|
||||
format!(
|
||||
"\"{}\" at \"{}\" will be used for identification",
|
||||
prefix, suffix
|
||||
)
|
||||
format!("\"{prefix}\" at \"{suffix}\" will be used for identification")
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
@@ -188,9 +188,9 @@ impl fmt::Display for ToolCallError {
|
||||
match self {
|
||||
ToolCallError::EmptyName => write!(f, "the tool name was empty"),
|
||||
ToolCallError::EmptyArgs => write!(f, "no arguments were provided"),
|
||||
ToolCallError::NotFound(ref name) => write!(f, "tool '{}' not found", name),
|
||||
ToolCallError::NotFound(ref name) => write!(f, "tool '{name}' not found"),
|
||||
ToolCallError::ArgParseFailure(ref msg) => {
|
||||
write!(f, "failed to parse arguments: {}", msg)
|
||||
write!(f, "failed to parse arguments: {msg}")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -375,8 +375,7 @@ impl PresentNotesCall {
|
||||
Ok(ToolCalls::PresentNotes(PresentNotesCall { note_ids }))
|
||||
}
|
||||
Err(e) => Err(ToolCallError::ArgParseFailure(format!(
|
||||
"{}, error: {}",
|
||||
args, e
|
||||
"{args}, error: {e}"
|
||||
))),
|
||||
}
|
||||
}
|
||||
@@ -476,8 +475,7 @@ impl QueryCall {
|
||||
match serde_json::from_str::<QueryCall>(args) {
|
||||
Ok(call) => Ok(ToolCalls::Query(call)),
|
||||
Err(e) => Err(ToolCallError::ArgParseFailure(format!(
|
||||
"{}, error: {}",
|
||||
args, e
|
||||
"{args}, error: {e}"
|
||||
))),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -285,7 +285,7 @@ impl<'a> DaveUi<'a> {
|
||||
}
|
||||
}
|
||||
ToolCalls::Invalid(err) => {
|
||||
ui.label(format!("invalid tool call: {:?}", err));
|
||||
ui.label(format!("invalid tool call: {err:?}"));
|
||||
}
|
||||
ToolCalls::Query(search_call) => {
|
||||
ui.allocate_ui_with_layout(
|
||||
|
||||
@@ -169,7 +169,7 @@ fn parse_img_response(
|
||||
let dyn_image = image::load_from_memory(&response.bytes)?;
|
||||
Ok(process_pfp_bitmap(imgtyp, dyn_image))
|
||||
} else {
|
||||
Err(format!("Expected image, found content-type {:?}", content_type).into())
|
||||
Err(format!("Expected image, found content-type {content_type:?}").into())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -328,7 +328,7 @@ fn generate_animation_frame(
|
||||
|
||||
TextureFrame {
|
||||
delay,
|
||||
texture: ctx.load_texture(format!("{}{}", url, index), color_img, Default::default()),
|
||||
texture: ctx.load_texture(format!("{url}{index}"), color_img, Default::default()),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ fn render_client(ui: &mut egui::Ui, note_cache: &mut NoteCache, note: &Note) {
|
||||
match cached_note.client.as_deref() {
|
||||
Some(client) if !client.is_empty() => {
|
||||
ui.horizontal(|ui| {
|
||||
secondary_label(ui, format!("via {}", client));
|
||||
secondary_label(ui, format!("via {client}"));
|
||||
});
|
||||
}
|
||||
_ => return,
|
||||
|
||||
@@ -31,7 +31,7 @@ pub fn display_name_widget<'a>(
|
||||
let username_resp = name.username.map(|username| {
|
||||
ui.add(
|
||||
Label::new(
|
||||
RichText::new(format!("@{}", username))
|
||||
RichText::new(format!("@{username}"))
|
||||
.size(16.0)
|
||||
.color(crate::colors::MID_GRAY),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user