Skip to content

Commit

Permalink
fix handling of toggle online/offline
Browse files Browse the repository at this point in the history
if connect was clicked rapidly, 2 connections might have been attempted
before isConnected was set true.
  • Loading branch information
mixmasala committed Oct 18, 2022
1 parent 015660c commit e7ff5d7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
6 changes: 3 additions & 3 deletions home.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,10 +253,10 @@ type OfflineClick struct {
// Event returns a ChooseContactClick event when a contact is chosen
func (p *HomePage) Event(gtx layout.Context) interface{} {
if p.connect.Clicked() {
if isConnected {
return OfflineClick{}
if !isConnected && !isConnecting {
return OnlineClick{}
}
return OnlineClick{}
return OfflineClick{}
}
// listen for pointer right click events on the addContact widget
if p.addContact.Clicked() {
Expand Down
1 change: 1 addition & 0 deletions katzen.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ func (a *App) update(gtx layout.Context) {
case OfflineClick:
go a.c.Offline()
isConnected = false
isConnecting = false
case OnlineClick:
isConnecting = true
go func() {
Expand Down

0 comments on commit e7ff5d7

Please sign in to comment.