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 | |
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 '')
-rw-r--r-- | ui/tray.go | 17 | ||||
-rw-r--r-- | ui/ui.go | 1 |
2 files changed, 15 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() { @@ -17,6 +17,7 @@ import ( var iconProvider *IconProvider var shouldQuitManagerWhenExiting = false +var startTime = time.Now() func RunUI() { runtime.LockOSThread() |