Skip to content

Commit

Permalink
fix auth indicator update on identity apply
Browse files Browse the repository at this point in the history
  • Loading branch information
yggverse committed Jan 28, 2025
1 parent 4203b91 commit 6501738
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 14 deletions.
18 changes: 12 additions & 6 deletions src/app/browser/window/tab/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,22 @@ impl Item {
});

action.ident.connect_activate({
let client = client.clone();
let page = page.clone();
let parent = tab_view.clone().upcast::<gtk::Widget>();
let profile = profile.clone();
let window_action = window_action.clone();
move || {
if let Some(uri) = page.navigation.uri() {
let scheme = uri.scheme();
if scheme == "gemini" || scheme == "titan" {
return identity::default(&window_action, &profile, &uri)
.present(Some(&parent));
if let Some(request) = page.navigation.uri() {
if ["gemini", "titan"].contains(&request.scheme().as_str()) {
return identity::default(&profile, &request, {
let client = client.clone();
let page = page.clone();
move || {
page.navigation.update(); // update indicators immediately
client.handle(&page.navigation.request(), false);
} // on apply
})
.present(Some(&parent));
}
}
identity::unsupported().present(Some(&parent));
Expand Down
6 changes: 3 additions & 3 deletions src/app/browser/window/tab/item/identity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ mod unsupported;
use default::Default;
use unsupported::Unsupported;

use super::{Profile, WindowAction};
use super::Profile;
use gtk::glib::Uri;
use std::rc::Rc;

/// Create new identity widget for Gemini protocol match given URI
pub fn default(window_action: &Rc<WindowAction>, profile: &Rc<Profile>, request: &Uri) -> Default {
Default::build(window_action, profile, request)
pub fn default(profile: &Rc<Profile>, request: &Uri, on_apply: impl Fn() + 'static) -> Default {
Default::build(profile, request, on_apply)
}

/// Create new identity widget for unknown request
Expand Down
9 changes: 4 additions & 5 deletions src/app/browser/window/tab/item/identity/default.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
mod widget;
use widget::{form::list::item::value::Value, Widget};

use super::{Profile, WindowAction};
use super::Profile;
use gtk::{glib::Uri, prelude::IsA};
use std::rc::Rc;

Expand All @@ -14,7 +14,7 @@ impl Default {
// Construct

/// Create new `Self` for given `Profile`
pub fn build(window_action: &Rc<WindowAction>, profile: &Rc<Profile>, request: &Uri) -> Self {
pub fn build(profile: &Rc<Profile>, request: &Uri, on_apply: impl Fn() + 'static) -> Self {
// Init widget
let widget = Rc::new(Widget::build(profile, request));

Expand All @@ -23,7 +23,6 @@ impl Default {
let profile = profile.clone();
let request = request.clone();
let widget = widget.clone();
let window_action = window_action.clone();
move |response| {
// Get option match user choice
let option = match response {
Expand Down Expand Up @@ -64,8 +63,8 @@ impl Default {
}
}

// Apply changes
window_action.reload.activate();
// Run callback function
on_apply()
}
});

Expand Down

0 comments on commit 6501738

Please sign in to comment.