Attempt to fix duplicated user tabs

This commit is contained in:
2026-02-03 10:38:41 +00:00
parent c260b8b231
commit 5c76729a6b
2 changed files with 9 additions and 6 deletions

View File

@@ -5,6 +5,7 @@ import (
"fmt" "fmt"
"github.com/diamondburned/gotk4/pkg/glib/v2" "github.com/diamondburned/gotk4/pkg/glib/v2"
"github.com/diamondburned/gotk4/pkg/gtk/v4" "github.com/diamondburned/gotk4/pkg/gtk/v4"
"github.com/diamondburned/gotk4/pkg/pango"
"gosrc.io/xmpp/stanza" "gosrc.io/xmpp/stanza"
) )
@@ -19,7 +20,9 @@ func scrollToBottomAfterUpdate(scrolledWindow *gtk.ScrolledWindow) {
func createTab(jid string, isMuc bool) bool { func createTab(jid string, isMuc bool) bool {
fmt.Println("Creating tab", jid, "isMuc:", isMuc) fmt.Println("Creating tab", jid, "isMuc:", isMuc)
_, ok := tabs.Load(jid) _, ok := tabs.Load(jid)
if !ok { _, uok := userdevices.Load(jid)
_, mok := mucmembers.Load(jid)
if !ok && !uok && !mok {
newTab := new(chatTab) newTab := new(chatTab)
newTab.isMuc = isMuc newTab.isMuc = isMuc
newTab.msgs = gtk.NewListBox() newTab.msgs = gtk.NewListBox()
@@ -60,6 +63,7 @@ func switchToTab(jid string, w *gtk.Window) {
u.Get(&ocu) u.Get(&ocu)
nick_label := gtk.NewLabel(JidMustParse(u.From).Resource) nick_label := gtk.NewLabel(JidMustParse(u.From).Resource)
nick_label.SetEllipsize(pango.EllipsizeEnd)
/* /*
affil_label := gtk.NewLabel("") affil_label := gtk.NewLabel("")
switch mu.MucUserItem.Affiliation { switch mu.MucUserItem.Affiliation {

View File

@@ -11,7 +11,6 @@ import (
"github.com/diamondburned/gotk4/pkg/glib/v2" "github.com/diamondburned/gotk4/pkg/glib/v2"
"github.com/diamondburned/gotk4/pkg/gtk/v4" "github.com/diamondburned/gotk4/pkg/gtk/v4"
"github.com/diamondburned/gotk4/pkg/gdkpixbuf/v2" "github.com/diamondburned/gotk4/pkg/gdkpixbuf/v2"
_ "github.com/kr/pretty"
"path/filepath" "path/filepath"
"github.com/BurntSushi/toml" "github.com/BurntSushi/toml"
@@ -86,6 +85,7 @@ var cancelBytes []byte
var cancelB64 string = base64.StdEncoding.EncodeToString(cancelBytes) var cancelB64 string = base64.StdEncoding.EncodeToString(cancelBytes)
var clientAssets map[string]gdk.Paintabler = make(map[string]gdk.Paintabler) var clientAssets map[string]gdk.Paintabler = make(map[string]gdk.Paintabler)
var lockedJIDs map[string]bool = make(map[string]bool)
func init() { func init() {
go func() { go func() {
@@ -187,7 +187,7 @@ func main() {
Jid: loadedConfig.Username + "/lambda." + str, Jid: loadedConfig.Username + "/lambda." + str,
Credential: xmpp.Password(loadedConfig.Password), Credential: xmpp.Password(loadedConfig.Password),
Insecure: loadedConfig.Insecure, Insecure: loadedConfig.Insecure,
StreamLogger: os.Stdout, // StreamLogger: os.Stdout,
} }
router := xmpp.NewRouter() router := xmpp.NewRouter()
@@ -317,7 +317,6 @@ func main() {
} else { } else {
typed_unit.Members.Delete(ocu.ID) typed_unit.Members.Delete(ocu.ID)
glib.IdleAdd(func() { glib.IdleAdd(func() {
//uiQueue <- func() {
b := gtk.NewLabel("") b := gtk.NewLabel("")
ba, ok := generatePresenceWidget(p).(*gtk.Label) ba, ok := generatePresenceWidget(p).(*gtk.Label)
if ok { if ok {
@@ -333,7 +332,6 @@ func main() {
} else { } else {
fmt.Println("Got message when the tab does not exist!") fmt.Println("Got message when the tab does not exist!")
} }
//}
}) })
} }
@@ -346,7 +344,7 @@ func main() {
_, mok := mucmembers.Load(user) _, mok := mucmembers.Load(user)
if !ok && !mok { // FIXME: The initial muc presence gets picked up from this check if !ok && !mok { // FIXME: The initial muc presence gets picked up from this check
ok := createTab(user, false) ok := createTab(user, false)
if ok { if ok && !lockedJIDs[user]{
userdevices.Store(user, userUnit{}) userdevices.Store(user, userUnit{})
b := gtk.NewButtonWithLabel(user) b := gtk.NewButtonWithLabel(user)
@@ -374,6 +372,7 @@ func main() {
} }
userdevices.Store(user, typed_unit) userdevices.Store(user, typed_unit)
lockedJIDs[user] = true
} }
time.Sleep(1 * time.Second) time.Sleep(1 * time.Second)
}) })