forked from sunglocto/lambda
In my true love's dying breath, she whispered to me 'never commit with descriptive messages'. So I kept her promise.
This commit is contained in:
@@ -17,7 +17,8 @@ func scrollToBottomAfterUpdate(scrolledWindow *gtk.ScrolledWindow) {
|
||||
}
|
||||
|
||||
func createTab(jid string, isMuc bool) {
|
||||
_, ok := tabs[jid]
|
||||
fmt.Println("Creating tab", jid, "isMuc:", isMuc)
|
||||
_, ok := tabs.Load(jid)
|
||||
if !ok {
|
||||
newTab := new(chatTab)
|
||||
newTab.isMuc = isMuc
|
||||
@@ -26,36 +27,47 @@ func createTab(jid string, isMuc bool) {
|
||||
newTab.msgs.SetShowSeparators(true)
|
||||
|
||||
newTab.msgs.Append(gtk.NewButtonWithLabel("Get past messages..."))
|
||||
tabs[jid] = newTab
|
||||
tabs.Store(jid, newTab)
|
||||
}
|
||||
}
|
||||
|
||||
func switchToTab(jid string) {
|
||||
current = jid
|
||||
scroller.SetChild(tabs[current].msgs)
|
||||
m, _ := mucmembers.Load(jid)
|
||||
ma := m.(mucUnit)
|
||||
mm := ma.Members
|
||||
gen := gtk.NewBox(gtk.OrientationVertical, 0)
|
||||
tab, ok := tabs.Load(current)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
||||
mm.Range(func(k, v any) bool {
|
||||
userbox := gtk.NewBox(gtk.OrientationHorizontal, 0)
|
||||
typed_tab := tab.(*chatTab)
|
||||
|
||||
u := v.(stanza.Presence)
|
||||
var mu MucUser
|
||||
var ocu OccupantID
|
||||
u.Get(&mu)
|
||||
u.Get(&ocu)
|
||||
scroller.SetChild(typed_tab.msgs)
|
||||
if typed_tab.isMuc {
|
||||
m, _ := mucmembers.Load(jid)
|
||||
ma := m.(mucUnit)
|
||||
mm := ma.Members
|
||||
gen := gtk.NewBox(gtk.OrientationVertical, 0)
|
||||
|
||||
nick_label := gtk.NewLabel(Jid.MustParse(u.From).Resourcepart())
|
||||
mm.Range(func(k, v any) bool {
|
||||
userbox := gtk.NewBox(gtk.OrientationHorizontal, 0)
|
||||
|
||||
userbox.Append(nick_label)
|
||||
u := v.(stanza.Presence)
|
||||
var mu MucUser
|
||||
var ocu OccupantID
|
||||
u.Get(&mu)
|
||||
u.Get(&ocu)
|
||||
|
||||
gen.Append(userbox)
|
||||
return true
|
||||
})
|
||||
nick_label := gtk.NewLabel(Jid.MustParse(u.From).Resourcepart())
|
||||
|
||||
memberList.SetChild(gen)
|
||||
userbox.Append(nick_label)
|
||||
|
||||
gen.Append(userbox)
|
||||
return true
|
||||
})
|
||||
|
||||
memberList.SetChild(gen)
|
||||
} else {
|
||||
memberList.SetChild(gtk.NewLabel(jid))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user