From a5633046e187d1992dce1667f0ab8ec4de9262de Mon Sep 17 00:00:00 2001 From: yggverse Date: Wed, 27 Nov 2024 19:10:27 +0200 Subject: [PATCH] create permanent gemini client object for page --- src/app/browser/window/tab/item/page.rs | 13 +++++++------ src/app/browser/window/tab/item/page/client.rs | 14 ++++++++++++++ 2 files changed, 21 insertions(+), 6 deletions(-) create mode 100644 src/app/browser/window/tab/item/page/client.rs diff --git a/src/app/browser/window/tab/item/page.rs b/src/app/browser/window/tab/item/page.rs index c41ec3bc..3f90775e 100644 --- a/src/app/browser/window/tab/item/page.rs +++ b/src/app/browser/window/tab/item/page.rs @@ -1,3 +1,4 @@ +mod client; mod content; mod database; mod error; @@ -6,6 +7,7 @@ mod meta; mod navigation; mod widget; +use client::Client; use content::Content; use error::Error; use input::Input; @@ -39,10 +41,11 @@ pub struct Page { browser_action: Rc, tab_action: Rc, // Components - pub navigation: Rc, + pub client: Rc, pub content: Rc, pub input: Rc, pub meta: Rc, + pub navigation: Rc, pub widget: Rc, } @@ -82,6 +85,7 @@ impl Page { browser_action: action.0, tab_action: action.2, // Components + client: Rc::new(Client::new()), content, navigation, input, @@ -413,9 +417,6 @@ impl Page { let input = self.input.clone(); let meta = self.meta.clone(); - // Init socket - let client = gemini::Client::new(); - // Return PEM string match request let certificate = match self .profile @@ -430,7 +431,7 @@ impl Page { }; // Listen for connection status updates - client.socket.connect_event({ + self.client.gemini.socket.connect_event({ let id = id.clone(); let meta = meta.clone(); let update = update.clone(); @@ -462,7 +463,7 @@ impl Page { }); // Create connection - client.request_async( + self.client.gemini.request_async( uri.clone(), None, Some(cancellable.clone()), diff --git a/src/app/browser/window/tab/item/page/client.rs b/src/app/browser/window/tab/item/page/client.rs new file mode 100644 index 00000000..64e1022d --- /dev/null +++ b/src/app/browser/window/tab/item/page/client.rs @@ -0,0 +1,14 @@ +pub struct Client { + pub gemini: gemini::Client, +} + +impl Client { + // Constructors + + /// Create new `Self` + pub fn new() -> Self { + Self { + gemini: gemini::Client::new(), + } + } +}