Update to match current oasisSdk version, fix bookmarks, update deps, and introduce a new bug

This commit is contained in:
2025-09-27 09:45:53 +01:00
parent f4d3f76841
commit 3f157d06c7
3 changed files with 58 additions and 33 deletions

6
go.mod
View File

@@ -1,15 +1,15 @@
module pi-im
go 1.24.6
go 1.25.1
require (
fyne.io/fyne/v2 v2.6.3
fyne.io/x/fyne v0.0.0-20250827163406-39fd826f385e
fyne.io/x/fyne v0.0.0-20250910205345-ecc79984d005
github.com/makeworld-the-better-one/go-isemoji v1.3.0
github.com/rrivera/identicon v0.0.0-20240116195454-d5ba35832c0d
github.com/shreve/musicwand v0.0.1
mellium.im/xmpp v0.22.0
pain.agency/oasis-sdk v0.0.0-20250831105702-85385dca3a95
pain.agency/oasis-sdk v0.0.0-20250918002549-5a45c8afedcd
)
require (

8
go.sum
View File

@@ -2,8 +2,8 @@ fyne.io/fyne/v2 v2.6.3 h1:cvtM2KHeRuH+WhtHiA63z5wJVBkQ9+Ay0UMl9PxFHyA=
fyne.io/fyne/v2 v2.6.3/go.mod h1:NGSurpRElVoI1G3h+ab2df3O5KLGh1CGbsMMcX0bPIs=
fyne.io/systray v1.11.0 h1:D9HISlxSkx+jHSniMBR6fCFOUjk1x/OOOJLa9lJYAKg=
fyne.io/systray v1.11.0/go.mod h1:RVwqP9nYMo7h5zViCBHri2FgjXF7H2cub7MAq4NSoLs=
fyne.io/x/fyne v0.0.0-20250827163406-39fd826f385e h1:oJM+HGkpSuq1J+JqUq/jo7KPrKj2K2/VIZlyus04w3Y=
fyne.io/x/fyne v0.0.0-20250827163406-39fd826f385e/go.mod h1:u3LF1EkElytjOT8OHxft16trctGndF9qpsoH6YIDOUU=
fyne.io/x/fyne v0.0.0-20250910205345-ecc79984d005 h1:CmdApAnt07juL0dhcFReFGpADUdRjjm0eDVJDS01uKE=
fyne.io/x/fyne v0.0.0-20250910205345-ecc79984d005/go.mod h1:kQFmF5meMIXnyCioLoCrXol5opruSS/PHYGKMBIE3SU=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/toml v1.4.0 h1:kuoIxZQy2WRRk1pttg9asf+WVv6tWQuBNVmK8+nqPr0=
github.com/BurntSushi/toml v1.4.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
@@ -113,5 +113,5 @@ mellium.im/xmlstream v0.15.4 h1:gLKxcWl4rLMUpKgtzrTBvr4OexPeO/edYus+uK3F6ZI=
mellium.im/xmlstream v0.15.4/go.mod h1:yXaCW2++fmVO4L9piKVkyLDqnCmictVYF7FDQW8prb4=
mellium.im/xmpp v0.22.0 h1:UthQVSwEAr7SNrmyc90c2ykGpVHxjn/3yw8Ey4+Im8s=
mellium.im/xmpp v0.22.0/go.mod h1:WSjq12nhREFD88Vy/0WD6Q8inE8t6a8w7QjzwivWitw=
pain.agency/oasis-sdk v0.0.0-20250831105702-85385dca3a95 h1:BcB7/hnMnQIU+pERvQRGFMt9i0/o8XCnHbK1kYG3/K4=
pain.agency/oasis-sdk v0.0.0-20250831105702-85385dca3a95/go.mod h1:eyvDgfpHo+9bdB/AkMEMZ3ETeoSONTULVx9X4w9kGAU=
pain.agency/oasis-sdk v0.0.0-20250918002549-5a45c8afedcd h1:oLKI4XqaHpJeegwRxRYH9hepFO4GYKCr6C7cLwqXTK8=
pain.agency/oasis-sdk v0.0.0-20250918002549-5a45c8afedcd/go.mod h1:eyvDgfpHo+9bdB/AkMEMZ3ETeoSONTULVx9X4w9kGAU=

75
main.go
View File

@@ -2,6 +2,7 @@ package main
import (
//core - required
"context"
"encoding/xml"
"errors"
"fmt"
@@ -29,6 +30,7 @@ import (
"github.com/shreve/musicwand/pkg/mpris"
// xmpp - required
"mellium.im/xmpp/bookmarks"
"mellium.im/xmpp/jid"
"mellium.im/xmpp/muc"
oasisSdk "pain.agency/oasis-sdk"
@@ -294,9 +296,9 @@ func CreateUITab(chatJidStr string) ChatTabUI {
scroller.CreateItem().Refresh()
vbox.Refresh()
/*
fyne.Do(func() {
scroller.RefreshItem(i)
})
fyne.Do(func() {
scroller.RefreshItem(i)
})
*/
},
)
@@ -305,7 +307,6 @@ func CreateUITab(chatJidStr string) ChatTabUI {
selectedId = id
}
myUITab := ChatTabUI{}
scroller.CreateItem()
@@ -452,8 +453,7 @@ func main() {
newlineIcon = " ⮡ "
}
client, err := oasisSdk.CreateClient(
&login)
client, err := oasisSdk.CreateClient(&login)
client.SetDmHandler(func(client *oasisSdk.XmppClient, msg *oasisSdk.XMPPChatMessage) {
correction := false
@@ -645,6 +645,24 @@ func main() {
})
}
})
client.SetPresenceHandler(func(client *oasisSdk.XmppClient, from jid.JID, p oasisSdk.UserPresence) {
fmt.Println(p, p.Indicator, p.Status)
})
client.SetBookmarkHandler(false, func(client *oasisSdk.XmppClient, bookmark bookmarks.Channel) {
if bookmark.Autojoin {
if bookmark.Nick == "" {
bookmark.Nick = client.Login.DisplayName
}
_, err := client.ConnectMuc(bookmark, oasisSdk.MucLegacyHistoryConfig{}, context.TODO())
if err != nil {
fmt.Println("ERROR: " + err.Error())
return
}
addChatTab(true, bookmark.JID, client.Login.DisplayName)
}
})
client.SetDeliveryReceiptHandler(
func(_ *oasisSdk.XmppClient, from jid.JID, id string) {
fmt.Printf("Delivered %s to %s", id, from.String())
@@ -674,11 +692,13 @@ func main() {
err = client.Connect()
if err != nil {
responseChan := make(chan bool)
fyne.Do(func() {
dialog.ShowConfirm("disconnected", fmt.Sprintf("the client disconnected. would you like to try and reconnect?\nreason:\n%s", err.Error()), func(b bool) {
responseChan <- b
}, w)
})
//fyne.Do(func() {
fmt.Println(err)
dialog.ShowConfirm("disconnected", fmt.Sprintf("the client disconnected. would you like to try and reconnect?\nreason:\n%s", err.Error()), func(b bool) {
responseChan <- b
}, w)
//})
if !<-responseChan {
connection = false
}
@@ -688,7 +708,6 @@ func main() {
a = app.New()
w = a.NewWindow("pi")
w.Resize(fyne.NewSize(500, 500))
@@ -945,9 +964,13 @@ func main() {
}
}
AppTabs.Selected().Text = fmt.Sprintf("%s (disconnected)", AppTabs.Selected().Text)
AppTabs.Items = append(AppTabs.Items[:AppTabs.SelectedIndex()], AppTabs.Items[AppTabs.SelectedIndex()+1:]...)
AppTabs.SelectIndex(0)
delete(client.MucChannels, activeMucJid)
//delete(chatTabs, activeMucJid)
err1, err2 := client.LeaveMuc(activeMucJid, "cya suckers!", context.TODO())
if err1 != nil || err2 != nil {
dialog.ShowError(errors.Join(err1, err2), w) // beautiful...
}
delete(UITabs, activeMucJid)
})
joinARoom := fyne.NewMenuItem("Join a room", func() {
@@ -1087,7 +1110,7 @@ func main() {
os.WriteFile("text.xml", b, os.ModeAppend)
})
jbookmarks := fyne.NewMenuItem("Join rooms in bookmarks", func() {
/*jbookmarks := fyne.NewMenuItem("Join rooms in bookmarks", func() {
// FIXME: Race condition
client.FetchBookmarks()
rooms := client.BookmarkCache()
@@ -1110,10 +1133,11 @@ func main() {
}()
}
})
*/
menu_help := fyne.NewMenu("π", mit, reconnect, licensesbtn, savedata)
menu_changeroom := fyne.NewMenu("Α", mic, beginADM, joinARoom, leaveRoom, jbookmarks)
menu_changeroom := fyne.NewMenu("Α", mic, beginADM, joinARoom, leaveRoom)
menu_configureview := fyne.NewMenu("Β", mia, jtt, jtb)
hafjag := fyne.NewMenuItem("Hafjag", func() {
entry.Text = "Hafjag"
@@ -1153,8 +1177,8 @@ func main() {
mycurrentplayingsong := fyne.NewMenuItem("Get currently playing song", func() {
// BEGIN PLATFORM SPECIFIC CODE
if isWindows() {
dialog.ShowError(errors.New("This feature is not supported on your operating system"), w)
if isWindows() {
dialog.ShowError(errors.New("this feature is not supported on your operating system"), w)
return
}
// END PLATFORM SPECIFIC CODE
@@ -1187,7 +1211,7 @@ func main() {
} else if a_ok {
newtext = fmt.Sprintf("I'm currently listening to a song by %s", artists[0])
} else {
dialog.ShowError(errors.New("error: There's a playing song, but we could not get any information."), w)
dialog.ShowError(errors.New("error: There's a playing song, but we could not get any information"), w)
return
}
@@ -1302,12 +1326,13 @@ func main() {
`)),
)
for _, mucJidStr := range login.MucsToJoin {
mucJid, err := jid.Parse(mucJidStr)
if err == nil {
addChatTab(true, mucJid, login.DisplayName)
}
}
/*
for _, mucJidStr := range login.MucsToJoin {
mucJid, err := jid.Parse(mucJidStr)
if err == nil {
addChatTab(true, mucJid, login.DisplayName)
}
}*/
for _, userJidStr := range DMs {
fmt.Println(userJidStr)