mirror of
https://github.com/netbirdio/netbird.git
synced 2026-04-16 15:26:40 +00:00
client/ui: more understandable connection lost messages
This commit is contained in:
@@ -280,6 +280,7 @@ type serviceClient struct {
|
||||
blockLANAccess bool
|
||||
|
||||
connected bool
|
||||
connectivityLost bool
|
||||
update *version.Update
|
||||
daemonVersion string
|
||||
updateIndicationLock sync.Mutex
|
||||
@@ -703,21 +704,41 @@ func (s *serviceClient) menuDownClick() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *serviceClient) onStatusFailed(err error) {
|
||||
log.Errorf("get client daemon service status: %v", err)
|
||||
if s.connected {
|
||||
s.connectivityLost = true
|
||||
s.app.SendNotification(fyne.NewNotification(
|
||||
"Warning",
|
||||
"NetBird client service controls were interrupted.\n"+
|
||||
"They should restore automatically.",
|
||||
))
|
||||
}
|
||||
s.setDisconnectedStatus()
|
||||
}
|
||||
func (s *serviceClient) onStatusSucceeded() {
|
||||
if s.connectivityLost {
|
||||
s.connectivityLost = false
|
||||
s.app.SendNotification(fyne.NewNotification(
|
||||
"Info",
|
||||
"NetBird client service controls were restored.",
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
func (s *serviceClient) updateStatus() error {
|
||||
conn, err := s.getSrvClient(defaultFailTimeout)
|
||||
if err != nil {
|
||||
s.onStatusFailed(err)
|
||||
return err
|
||||
}
|
||||
err = backoff.Retry(func() error {
|
||||
status, err := conn.Status(s.ctx, &proto.StatusRequest{})
|
||||
if err != nil {
|
||||
log.Errorf("get service status: %v", err)
|
||||
if s.connected {
|
||||
s.app.SendNotification(fyne.NewNotification("Error", "Connection to service lost"))
|
||||
}
|
||||
s.setDisconnectedStatus()
|
||||
s.onStatusFailed(err)
|
||||
return err
|
||||
}
|
||||
s.onStatusSucceeded()
|
||||
|
||||
s.updateIndicationLock.Lock()
|
||||
defer s.updateIndicationLock.Unlock()
|
||||
|
||||
Reference in New Issue
Block a user