From faac9c60fe33141deeab80583f760f70a17dc7f8 Mon Sep 17 00:00:00 2001 From: yggverse Date: Fri, 7 Feb 2025 20:38:46 +0200 Subject: [PATCH] keep original header to have re-send ability --- src/app/browser/window/tab/item/page/input/titan.rs | 8 ++++---- .../browser/window/tab/item/page/input/titan/control.rs | 4 ++-- .../window/tab/item/page/input/titan/control/options.rs | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/app/browser/window/tab/item/page/input/titan.rs b/src/app/browser/window/tab/item/page/input/titan.rs index a286b59d..adeaa4c0 100644 --- a/src/app/browser/window/tab/item/page/input/titan.rs +++ b/src/app/browser/window/tab/item/page/input/titan.rs @@ -18,10 +18,10 @@ pub trait Titan { impl Titan for gtk::Box { fn titan(callback: impl Fn(Header, Bytes, Box) + 'static) -> Self { use gtk::{glib::uuid_string_random, prelude::ButtonExt, Label, TextView}; - use std::{cell::Cell, rc::Rc}; + use std::{cell::RefCell, rc::Rc}; // Init components - let header = Rc::new(Cell::new(Header { + let header = Rc::new(RefCell::new(Header { mime: None, token: None, })); @@ -79,7 +79,7 @@ impl Titan for gtk::Box { use control::Upload; this.set_uploading(); callback( - header.take(), // @TODO copy? + header.borrow().clone(), // keep original header to have re-send ability match notebook.current_page().unwrap() { 0 => text.to_bytes(), 1 => file.to_bytes().unwrap(), @@ -87,7 +87,7 @@ impl Titan for gtk::Box { }, Box::new({ let this = this.clone(); - move || this.set_resend() // on failure + move || this.set_resend() // re-activate button on failure }), ) }); diff --git a/src/app/browser/window/tab/item/page/input/titan/control.rs b/src/app/browser/window/tab/item/page/input/titan/control.rs index 1da9fe65..e1256fdf 100644 --- a/src/app/browser/window/tab/item/page/input/titan/control.rs +++ b/src/app/browser/window/tab/item/page/input/titan/control.rs @@ -9,7 +9,7 @@ use gtk::{ Align, Box, Button, Label, Orientation, }; use options::Options; -use std::{cell::Cell, rc::Rc}; +use std::{cell::RefCell, rc::Rc}; pub use upload::Upload; pub struct Control { @@ -22,7 +22,7 @@ impl Control { // Constructors /// Build new `Self` - pub fn build(header: &Rc>) -> Self { + pub fn build(header: &Rc>) -> Self { // Init components let counter = Label::counter(); let options = Button::options(header); diff --git a/src/app/browser/window/tab/item/page/input/titan/control/options.rs b/src/app/browser/window/tab/item/page/input/titan/control/options.rs index 4dc709d0..d59e304f 100644 --- a/src/app/browser/window/tab/item/page/input/titan/control/options.rs +++ b/src/app/browser/window/tab/item/page/input/titan/control/options.rs @@ -3,14 +3,14 @@ use gtk::{ prelude::{ButtonExt, WidgetExt}, Button, }; -use std::{cell::Cell, rc::Rc}; +use std::{cell::RefCell, rc::Rc}; pub trait Options { - fn options(header: &Rc>) -> Self; + fn options(header: &Rc>) -> Self; } impl Options for Button { - fn options(header: &Rc>) -> Self { + fn options(header: &Rc>) -> Self { let button = Button::builder() .icon_name("emblem-system-symbolic") .tooltip_text("Options")