Skip to content

Commit bacf1f7

Browse files
don't add new tunnel if logged out
1 parent 07763d1 commit bacf1f7

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

ui/src/main.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,7 @@ fn App() -> Element {
297297
}
298298

299299
let mut open_add_tunnel_from_tray = use_signal(|| false);
300+
let mut login_state_for_tray = use_signal(|| None::<lib::datum_cloud::LoginState>);
300301

301302
// Create tray when app state is ready. Must run before early return.
302303
#[cfg(feature = "desktop")]
@@ -328,6 +329,11 @@ fn App() -> Element {
328329
window.set_visible(false);
329330
}
330331
"new_tunnel" => {
332+
if login_state_for_tray() == Some(lib::datum_cloud::LoginState::Missing)
333+
|| login_state_for_tray().is_none()
334+
{
335+
return;
336+
}
331337
window.set_visible(true);
332338
window.set_focus();
333339
open_add_tunnel_from_tray.set(true);
@@ -351,6 +357,11 @@ fn App() -> Element {
351357
provide_context(auth_changed);
352358

353359
let state_for_auth_watch = consume_context::<AppState>();
360+
use_effect(move || {
361+
let _ = auth_changed();
362+
let state = consume_context::<AppState>();
363+
login_state_for_tray.set(Some(state.datum().login_state()));
364+
});
354365
use_future(move || {
355366
let state_for_auth_watch = state_for_auth_watch.clone();
356367
let mut auth_changed = auth_changed;

0 commit comments

Comments
 (0)