diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-05-07 09:56:56 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-05-07 10:59:06 +0200 |
commit | b3eb50ae6bdae591df1cf3948333a56458f405b5 (patch) | |
tree | cb9da7b9030cd19e2aa5eb61952a50ab8c341207 /ui/tray.go | |
parent | ui: select first tunnel even when showing updates tab (diff) | |
download | wireguard-windows-b3eb50ae6bdae591df1cf3948333a56458f405b5.tar.xz wireguard-windows-b3eb50ae6bdae591df1cf3948333a56458f405b5.zip |
ui: defer update popup until 3 seconds after app start
Diffstat (limited to 'ui/tray.go')
-rw-r--r-- | ui/tray.go | 17 |
1 files changed, 14 insertions, 3 deletions
@@ -10,6 +10,7 @@ import ( "golang.zx2c4.com/wireguard/windows/conf" "sort" "strings" + "time" "github.com/lxn/walk" "golang.zx2c4.com/wireguard/windows/service" @@ -303,7 +304,6 @@ func (tray *Tray) UpdateFound() { action := walk.NewAction() action.SetText("An Update is Available!") icon, _ := loadSystemIcon("imageres", 1) - defer icon.Dispose() bitmap, _ := walk.NewBitmapFromIcon(icon, walk.Size{tray.mtw.DPI() / 6, tray.mtw.DPI() / 6}) //TODO: This should use dynamic DPI. action.SetImage(bitmap) action.SetDefault(true) @@ -318,8 +318,19 @@ func (tray *Tray) UpdateFound() { tray.clicked = showUpdateTab tray.ContextMenu().Actions().Insert(tray.ContextMenu().Actions().Len()-2, action) - //TODO: make clicking on this call showUpdateTab - tray.ShowCustom("WireGuard Update Available", "An update to WireGuard is now available. You are advised to update as soon as possible.", icon) + showUpdateBalloon := func() { + tray.ShowCustom("WireGuard Update Available", "An update to WireGuard is now available. You are advised to update as soon as possible.", icon) + defer icon.Dispose() + } + + timeSinceStart := time.Now().Sub(startTime) + if timeSinceStart < time.Second*3 { + time.AfterFunc(time.Second*3-timeSinceStart, func() { + tray.mtw.Synchronize(showUpdateBalloon) + }) + } else { + showUpdateBalloon() + } } func (tray *Tray) onManageTunnels() { |