Skip to content

Commit

Permalink
#328 - Avoids appending resources if there aren't any.
Browse files Browse the repository at this point in the history
  • Loading branch information
iapazmino committed Sep 5, 2017
1 parent 311c51a commit 6d8fc01
Showing 1 changed file with 15 additions and 19 deletions.
34 changes: 15 additions & 19 deletions gui/roster.go
Expand Up @@ -245,28 +245,24 @@ func (r *roster) createAccountPeerPopup(jid string, account *account, bt gdki.Ev

func (r *roster) appendResourcesAsMenuItems(jid string, account *account, menuItem gtki.MenuItem) {
peer, ok := r.ui.getPeer(account, jid)
innerMenu, _ := g.gtk.MenuNew()

if !ok {
innerMenu.SetVisible(false)
menuItem.SetSubmenu(innerMenu)
return
}

for _, resource := range peer.Resources() {
fullJid := jid + "/" + resource
item, _ := g.gtk.CheckMenuItemNewWithMnemonic(resource)
item.Connect("activate",
func() {
doInUIThread(func() {
r.openConversationView(account, fullJid, true)
if ok && peer.HasResources() {
innerMenu, _ := g.gtk.MenuNew()

for _, resource := range peer.Resources() {
fullJid := jid + "/" + resource
item, _ := g.gtk.CheckMenuItemNewWithMnemonic(resource)
item.Connect("activate",
func() {
doInUIThread(func() {
r.openConversationView(account, fullJid, true)
})
})
})
innerMenu.Append(item)
}
innerMenu.Append(item)
}

innerMenu.SetVisible(peer.HasResources())
menuItem.SetSubmenu(innerMenu)
menuItem.SetSubmenu(innerMenu)
}
}

func (r *roster) createAccountPopup(jid string, account *account, bt gdki.EventButton) {
Expand Down

0 comments on commit 6d8fc01

Please sign in to comment.