forked from sunglocto/pi-im
Update to match current oasisSdk version, fix bookmarks, update deps, and introduce a new bug
This commit is contained in:
77
main.go
77
main.go
@@ -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"
|
||||
@@ -210,7 +212,7 @@ func CreateUITab(chatJidStr string) ChatTabUI {
|
||||
content := vbox.Objects[2].(*widget.Label)
|
||||
btn := vbox.Objects[3].(*widget.Button)
|
||||
if chatTabs[chatJidStr].Messages[i].Important {
|
||||
content.Importance = widget.DangerImportance
|
||||
content.Importance = widget.DangerImportance
|
||||
}
|
||||
btn.Hidden = true // Hide by default
|
||||
msgContent := chatTabs[chatJidStr].Messages[i].Content
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user