@@ -26,7 +26,9 @@ func NewUI() *UI {
2626 a := app .NewWithID ("NetBird-update" )
2727
2828 return & UI {
29- app : a ,
29+ app : a ,
30+ resultErrCh : make (chan error , 1 ),
31+ resultOkCh : make (chan struct {}, 1 ),
3032 }
3133}
3234
@@ -61,13 +63,15 @@ func (u *UI) ShowUpdateProgress(ctx context.Context, version string) {
6163 for {
6264 select {
6365 case <- ctx .Done ():
66+ u .wUpdateProgress .SetCloseIntercept (u .closeApp )
6467 u .showInstallerResult (statusLabel , ctx .Err ())
6568 return
6669 case err := <- u .resultErrCh :
70+ u .wUpdateProgress .SetCloseIntercept (u .closeApp )
6771 u .showInstallerResult (statusLabel , err )
6872 return
6973 case <- u .resultOkCh :
70- u .wUpdateProgress .SetCloseIntercept (nil )
74+ u .wUpdateProgress .SetCloseIntercept (u . closeApp )
7175 u .wUpdateProgress .Close ()
7276 return
7377 case <- ticker .C :
@@ -99,7 +103,6 @@ func (u *UI) SetError(err error) {
99103}
100104
101105func (u * UI ) showInstallerResult (statusLabel * widget.Label , err error ) {
102- u .wUpdateProgress .SetCloseIntercept (nil )
103106 switch {
104107 case errors .Is (err , context .DeadlineExceeded ):
105108 log .Warn ("update timed out" )
@@ -115,6 +118,11 @@ func (u *UI) showInstallerResult(statusLabel *widget.Label, err error) {
115118 }
116119}
117120
121+ func (u * UI ) closeApp () {
122+ log .Infof ("close updater UI app" )
123+ u .app .Quit ()
124+ }
125+
118126// dotUpdater returns a closure that cycles through dots for a loading animation.
119127func dotUpdater () func () string {
120128 dotCount := 0
0 commit comments