Skip to content

Commit

Permalink
Seticon only when status changes
Browse files Browse the repository at this point in the history
This prevents a memory leak with the systray lib
when setting the icon every 2 seconds causes a large memory consumption

see getlantern/systray#135
  • Loading branch information
mlsmaycon committed Oct 12, 2022
1 parent b4e03f4 commit 3c8e18d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions client/ui/client_ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,12 +324,12 @@ func (s *serviceClient) updateStatus() error {
return err
}

if status.Status == string(internal.StatusConnected) {
if status.Status == string(internal.StatusConnected) && !s.mUp.Disabled() {
systray.SetIcon(s.icConnected)
s.mStatus.SetTitle("Connected")
s.mUp.Disable()
s.mDown.Enable()
} else {
} else if status.Status != string(internal.StatusConnected) && s.mUp.Disabled() {
systray.SetIcon(s.icDisconnected)
s.mStatus.SetTitle("Disconnected")
s.mDown.Disable()
Expand Down

0 comments on commit 3c8e18d

Please sign in to comment.