aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--ui/ui.go18
1 files changed, 10 insertions, 8 deletions
diff --git a/ui/ui.go b/ui/ui.go
index 4acd4a76..7b9a8ce0 100644
--- a/ui/ui.go
+++ b/ui/ui.go
@@ -52,6 +52,13 @@ func RunUI() {
defer tray.Dispose()
// Bind to updates
+ setTunnelState := func(tunnel *service.Tunnel, state service.TunnelState, showNotifications bool) {
+ mtw.Synchronize(func() {
+ mtw.SetTunnelState(tunnel, state)
+ tray.SetTunnelStateWithNotification(tunnel, state, showNotifications)
+ })
+ }
+
service.IPCClientRegisterTunnelChange(func(tunnel *service.Tunnel, state service.TunnelState, err error) {
if err == nil {
return
@@ -66,12 +73,8 @@ func RunUI() {
} else {
tray.ShowError("WireGuard Tunnel Error", err.Error())
}
- })
- service.IPCClientRegisterTunnelChange(func(tunnel *service.Tunnel, state service.TunnelState, err error) {
- tray.SetTunnelStateWithNotification(tunnel, state, err == nil)
- })
- service.IPCClientRegisterTunnelChange(func(tunnel *service.Tunnel, state service.TunnelState, err error) {
- mtw.SetTunnelState(tunnel, state)
+
+ setTunnelState(tunnel, state, err == nil)
})
// Fetch current state
@@ -85,8 +88,7 @@ func RunUI() {
if err != nil {
continue
}
- tray.SetTunnelStateWithNotification(&tunnel, state, false)
- mtw.SetTunnelState(&tunnel, state)
+ setTunnelState(&tunnel, state, false)
}
}()