From 96f2edddfbf29cddf49e273467e8e2e54106be93 Mon Sep 17 00:00:00 2001 From: yggverse Date: Tue, 21 Jan 2025 19:49:43 +0200 Subject: [PATCH] integrate source view feature --- src/app/browser/window/tab.rs | 4 +-- .../window/tab/item/client/driver/gemini.rs | 25 ++++++++++--------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/app/browser/window/tab.rs b/src/app/browser/window/tab.rs index 8f1ca968..2474de93 100644 --- a/src/app/browser/window/tab.rs +++ b/src/app/browser/window/tab.rs @@ -219,7 +219,7 @@ impl Tab { pub fn save_as(&self, page_position: Option) { if let Some(item) = self.item(page_position) { item.page.navigation.request.to_download(); - todo!() + self.window_action.reload.activate(); } } @@ -227,7 +227,7 @@ impl Tab { pub fn source(&self, page_position: Option) { if let Some(item) = self.item(page_position) { item.page.navigation.request.to_source(); - todo!() + self.window_action.reload.activate(); } } diff --git a/src/app/browser/window/tab/item/client/driver/gemini.rs b/src/app/browser/window/tab/item/client/driver/gemini.rs index 257c695a..7b93690e 100644 --- a/src/app/browser/window/tab/item/client/driver/gemini.rs +++ b/src/app/browser/window/tab/item/client/driver/gemini.rs @@ -74,7 +74,13 @@ impl Gemini { // Actions - pub fn handle(&self, uri: Uri, feature: Feature, cancellable: Cancellable, is_history: bool) { + pub fn handle( + &self, + uri: Uri, + feature: Feature, + cancellable: Cancellable, + is_snap_history: bool, + ) { // Move focus out from navigation entry self.page .browser_action @@ -101,7 +107,7 @@ impl Gemini { self.tab_page.set_loading(true); - if is_history { + if is_snap_history { snap_history(&self.page, None); } @@ -232,16 +238,11 @@ impl Gemini { cancellable.clone(), move |result| match result { Ok(text) => { - /* @TODO refactor features - let widget = if is_source_request { - page.content.to_text_source(&data) + let widget = if matches!(feature, Feature::Source) { + page.content.to_text_source(&text.to_string()) } else { - page.content.to_text_gemini(&uri, &data) - };*/ - - let widget = page - .content - .to_text_gemini(&uri, &text.to_string()); + page.content.to_text_gemini(&uri, &text.to_string()) + }; // Connect `TextView` widget, update `search` model page.search.set(Some(widget.text_view)); @@ -371,7 +372,7 @@ impl Gemini { .set_text(&uri.to_string()); } redirects.replace(total); - page.tab_action.load.activate(Some(&target.to_string()), is_history); + page.tab_action.load.activate(Some(&target.to_string()), is_snap_history); } } Err(e) => {