aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorAlexander Neumann <alexander.neumann@picos-software.com>2019-04-08 16:03:34 +0200
committerAlexander Neumann <alexander.neumann@picos-software.com>2019-04-23 11:04:59 +0200
commit7988107926bd2091f4d9f9fb48f5926154e7a664 (patch)
tree9ff94f8b159aa3e31fe47b84c441f5ca09316732
parentui: handle adding and removing of tunnels for tray (diff)
downloadwireguard-windows-7988107926bd2091f4d9f9fb48f5926154e7a664.tar.xz
wireguard-windows-7988107926bd2091f4d9f9fb48f5926154e7a664.zip
ui: initialize TunnelsView model from service.IPCClientTunnels
Signed-off-by: Alexander Neumann <alexander.neumann@picos-software.com> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to '')
-rw-r--r--ui/tunnelsview.go18
1 files changed, 5 insertions, 13 deletions
diff --git a/ui/tunnelsview.go b/ui/tunnelsview.go
index 08bc1f21..faad2383 100644
--- a/ui/tunnelsview.go
+++ b/ui/tunnelsview.go
@@ -71,7 +71,10 @@ func NewTunnelsView(parent walk.Container) (*TunnelsView, error) {
}
disposables.Add(tv)
- model := &TunnelModel{}
+ model := new(TunnelModel)
+ if model.tunnels, err = service.IPCClientTunnels(); err != nil {
+ return nil, err
+ }
tv.SetModel(model)
tv.SetLastColumnStretched(true)
@@ -133,18 +136,7 @@ func (tv *TunnelsView) SetTunnelState(tunnel *service.Tunnel, state service.Tunn
}
if idx != -1 {
- // we don't do anything with the state right now
+ tv.model.PublishRowChanged(idx)
return
}
-
- // New tunnel, add it
- tv.model.tunnels = append(tv.model.tunnels, *tunnel)
- tv.model.Sort(0, walk.SortAscending)
- for i, _ := range tv.model.tunnels {
- if tv.model.tunnels[i].Name == tunnel.Name {
- idx = i
- }
- }
-
- tv.model.PublishRowsInserted(idx, idx)
}