remove extra copy

This commit is contained in:
yggverse 2025-06-29 17:05:02 +03:00
parent 1516531ad1
commit 565748ae58

View file

@ -152,7 +152,7 @@ impl Nex {
move |r| { move |r| {
event( event(
&p, &p,
&match r { match r {
Ok(()) => "Disconnected".to_string(), Ok(()) => "Disconnected".to_string(),
Err(e) => e.to_string(), Err(e) => e.to_string(),
}, },
@ -211,7 +211,7 @@ impl Nex {
move |r| { move |r| {
event( event(
&p, &p,
&match r { match r {
Ok(()) => { Ok(()) => {
"Disconnected".to_string() "Disconnected".to_string()
} }
@ -239,9 +239,9 @@ impl Nex {
} }
} }
fn event(p: &Page, e: &str, s: Option<usize>) { fn event(p: &Page, e: String, s: Option<usize>) {
let mut i = p.navigation.request.info.borrow_mut(); let mut i = p.navigation.request.info.borrow_mut();
i.add_event(e.to_string()).set_size(s); i.add_event(e).set_size(s);
p.navigation.request.update_secondary_icon(&i) p.navigation.request.update_secondary_icon(&i)
} }
@ -266,7 +266,7 @@ fn render(
p.set_title(&uri_to_title(&u)); p.set_title(&uri_to_title(&u));
p.content.to_image(&Texture::for_pixbuf(&b)); p.content.to_image(&Texture::for_pixbuf(&b));
p.set_progress(0.0); p.set_progress(0.0);
event(&p, "Completed", Some(s)) event(&p, "Completed".to_string(), Some(s))
} }
Err(e) => failure(&p, &e.to_string()), Err(e) => failure(&p, &e.to_string()),
}) })
@ -286,14 +286,14 @@ fn render(
} else { } else {
p.content.to_text_nex(&u, d) p.content.to_text_nex(&u, d)
}; };
event(&p, "Parsed", Some(s)); event(&p, "Parsed".to_string(), Some(s));
p.search.set(Some(t.text_view)); p.search.set(Some(t.text_view));
p.set_title(&match t.meta.title { p.set_title(&match t.meta.title {
Some(t) => t.into(), // @TODO Some(t) => t.into(), // @TODO
None => uri_to_title(&u), None => uri_to_title(&u),
}); });
p.set_progress(0.0); p.set_progress(0.0);
event(&p, "Completed", Some(s)) event(&p, "Completed".to_string(), Some(s))
} }
Err(e) => failure(&p, &e.to_string()), Err(e) => failure(&p, &e.to_string()),
}, },
@ -310,7 +310,7 @@ fn render(
fn download(s: SocketConnection, (p, u): (Rc<Page>, Uri), c: Cancellable) { fn download(s: SocketConnection, (p, u): (Rc<Page>, Uri), c: Cancellable) {
use crate::tool::Format; use crate::tool::Format;
use ggemini::gio::file_output_stream; use ggemini::gio::file_output_stream;
event(&p, "Download begin", None); event(&p, "Download begin".to_string(), None);
let t = crate::tool::uri_to_title(&u) let t = crate::tool::uri_to_title(&u)
.trim_matches(std::path::MAIN_SEPARATOR) .trim_matches(std::path::MAIN_SEPARATOR)
.to_string(); .to_string();
@ -338,7 +338,7 @@ fn download(s: SocketConnection, (p, u): (Rc<Page>, Uri), c: Cancellable) {
move |_, total| { move |_, total| {
const T: &str = "Received"; const T: &str = "Received";
let t = format!("{T} {}...", total.bytes()); let t = format!("{T} {}...", total.bytes());
event(&p, T, Some(total)); event(&p, T.to_string(), Some(total));
p.set_title(&t); p.set_title(&t);
a.update.activate(&t) a.update.activate(&t)
} }
@ -364,7 +364,7 @@ fn download(s: SocketConnection, (p, u): (Rc<Page>, Uri), c: Cancellable) {
move |r| { move |r| {
event( event(
&p, &p,
&match r { match r {
Ok(()) => "Disconnected".to_string(), Ok(()) => "Disconnected".to_string(),
Err(e) => e.to_string(), Err(e) => e.to_string(),
}, },