lambda is free of this insane bug

This commit is contained in:
2026-07-17 17:15:41 +01:00
parent 120b0c2647
commit 006b43a590
9 changed files with 263 additions and 240 deletions
+50 -34
View File
@@ -110,6 +110,37 @@ func generateMessageWidget(p stanza.Packet) gtk.Widgetter {
sid := StanzaID{}
m.Get(&sid)
ocu := OccupantID{}
m.Get(&ocu)
id := JidMustParse(m.From).Resource
name := id
custom_nick, ok := loadedConfig.CustomNicks[ocu.ID]
if ok {
name = custom_nick
}
// Avatar hash custom nicks. This code needs to be optimised.
mo, ok := mucmembers.Load(JidMustParse(m.From).Bare())
if ok {
mm, ok := mo.(mucUnit)
if ok {
mmm, ok := mm.Members.Load(id)
if ok {
u := mmm.(stanza.Presence)
var vcu VCardUpdate
ok = u.Get(&vcu)
if ok {
av_nick, ok := loadedConfig.CustomNicksAV[vcu.Photo]
if ok {
name = av_nick
}
}
}
}
}
padding := 10
orientation := gtk.OrientationVertical
if loadedConfig.CompactMode {
@@ -177,6 +208,23 @@ func generateMessageWidget(p stanza.Packet) gtk.Widgetter {
})
rc_box.Append(quote)
vp := gtk.NewButtonWithLabel("View profile")
vp.ConnectClicked(func() {
mo, ok := mucmembers.Load(JidMustParse(m.From).Bare())
if ok {
mm, ok := mo.(mucUnit)
if ok {
mmm, ok := mm.Members.Load(id)
if ok {
u := mmm.(stanza.Presence)
showUserWindow(u, name)
}
}
}
})
rc_box.Append(vp)
popover.SetChild(rc_box)
rect := gdk.NewRectangle(x, y, 1, 1)
popover.SetPointingTo(&rect)
@@ -185,50 +233,18 @@ func generateMessageWidget(p stanza.Packet) gtk.Widgetter {
mainBox.AddController(gesture)
ocu := OccupantID{}
m.Get(&ocu)
id := JidMustParse(m.From).Resource
name := id
// Avatar hash custom nicks. This code needs to be optimised.
mo, ok := mucmembers.Load(JidMustParse(m.From).Bare())
if ok {
mm, ok := mo.(mucUnit)
if ok {
mmm, ok := mm.Members.Load(id)
if ok {
u := mmm.(stanza.Presence)
var vcu VCardUpdate
ok = u.Get(&vcu)
if ok {
av_nick, ok := loadedConfig.CustomNicksAV[vcu.Photo]
if ok {
name = av_nick
}
}
}
}
}
custom_nick, ok := loadedConfig.CustomNicks[ocu.ID]
if ok {
name = custom_nick
}
if name == "" {
name = JidMustParse(m.From).Bare()
}
if loadedConfig.CompactMode {
al := gtk.NewLabel(id)
al := gtk.NewLabel(name)
ycbcr := xmpp_color.String(id, 255, loadedConfig.CVD)
r, g, b, _ := ycbcr.RGBA()
hexcolor := fmt.Sprintf("#%02x%02x%02x", r, g, b)
al.SetMarkup(fmt.Sprintf("<span foreground='%s'>%s</span>", hexcolor, id))
al.SetMarkup(fmt.Sprintf("<span foreground='%s'>%s</span>", hexcolor, name))
al.SetSelectable(true)
al.SetVAlign(gtk.AlignStart)
mainBox.Append(al)