@@ -48,9 +48,10 @@ type trayUI struct {
4848 installItem * application.MenuItem
4949 healthOK bool
5050 healthKnown bool
51- strategyItems map [dpi.Strategy ]* application.MenuItem
52- dnsItems map [dns.Provider ]* application.MenuItem
53- domainItems map [proxy.AllowlistPreset ]* application.MenuItem
51+ strategyItems map [dpi.Strategy ]* application.MenuItem
52+ dnsItems map [dns.Provider ]* application.MenuItem
53+ domainItems map [proxy.AllowlistPreset ]* application.MenuItem
54+ promptedUpdateVer string
5455}
5556
5657func setupTray (deps trayDeps ) * trayUI {
@@ -379,9 +380,9 @@ func (ui *trayUI) runHealthCheck() {
379380 }
380381}
381382
382- func (ui * trayUI ) checkUpdates (manual bool ) {
383+ func (ui * trayUI ) checkUpdates (manual bool ) bool {
383384 if ! ui .checkMu .TryLock () {
384- return
385+ return false
385386 }
386387 defer ui .checkMu .Unlock ()
387388
@@ -391,15 +392,17 @@ func (ui *trayUI) checkUpdates(manual bool) {
391392 available , err := ui .deps .updater .Check (ctx , skipped )
392393 if err != nil {
393394 ui .refreshMenu ()
394- return
395+ ui .syncUpdateTooltip ()
396+ return false
395397 }
396398 ui .deps .prefs .Update (func (p * Preferences ) { p .LastUpdateCheck = time .Now () })
397399 if available && ui .deps .prefs .Get ().AutoUpdate {
398400 _ = ui .deps .updater .Download (ctx )
399401 }
400- if manual {
401- ui .refreshMenu ()
402- }
402+ ui .refreshMenu ()
403+ ui .syncUpdateTooltip ()
404+ ui .maybePromptInstall (manual )
405+ return true
403406}
404407
405408func (ui * trayUI ) installUpdate () {
@@ -421,6 +424,28 @@ func (ui *trayUI) installUpdate() {
421424
422425func (ui * trayUI ) onUpdateChange () {
423426 ui .refreshMenu ()
427+ ui .syncUpdateTooltip ()
428+ }
429+
430+ func (ui * trayUI ) syncUpdateTooltip () {
431+ if ui .tray == nil {
432+ return
433+ }
434+ ui .tray .SetTooltip (ui .updateStatusLabel ())
435+ }
436+
437+ func (ui * trayUI ) maybePromptInstall (manual bool ) {
438+ if manual || ui .deps .updater .State () != update .StateReady {
439+ return
440+ }
441+ ver := ui .deps .updater .Latest ().TagName
442+ if ver == "" || ver == ui .promptedUpdateVer {
443+ return
444+ }
445+ ui .promptedUpdateVer = ver
446+ if showUpdateReadyPrompt (ui .lang (), ver ) {
447+ ui .installUpdate ()
448+ }
424449}
425450
426451func (ui * trayUI ) updateStatusLabel () string {
@@ -475,10 +500,26 @@ func menuFromItems(items []*application.MenuItem) *application.Menu {
475500
476501func startUpdateScheduler (prefs * preferenceStore , svc * update.Service , ui * trayUI ) {
477502 go func () {
478- select {
479- case <- time .After (config .UpdateCheckDelay ):
480- ui .checkUpdates (false )
481- case <- ui .stopCh :
503+ retryWaits := []time.Duration {
504+ config .UpdateCheckDelay ,
505+ time .Minute ,
506+ 5 * time .Minute ,
507+ }
508+ var elapsed time.Duration
509+ for _ , wait := range retryWaits {
510+ wait -= elapsed
511+ if wait < 0 {
512+ wait = 0
513+ }
514+ elapsed += wait
515+ select {
516+ case <- time .After (wait ):
517+ if ui .checkUpdates (false ) {
518+ return
519+ }
520+ case <- ui .stopCh :
521+ return
522+ }
482523 }
483524 }()
484525 go func () {
0 commit comments