add status to member list, @here, more delta menu buttons, and choice to suspend to desktop when hitting close
This commit is contained in:
168
main.go
168
main.go
@@ -439,6 +439,7 @@ func main() {
|
|||||||
client.SetDmHandler(func(client *oasisSdk.XmppClient, msg *oasisSdk.XMPPChatMessage) {
|
client.SetDmHandler(func(client *oasisSdk.XmppClient, msg *oasisSdk.XMPPChatMessage) {
|
||||||
correction := false
|
correction := false
|
||||||
userJidStr := msg.From.Bare().String()
|
userJidStr := msg.From.Bare().String()
|
||||||
|
fmt.Println(userJidStr)
|
||||||
tab, ok := chatTabs[userJidStr]
|
tab, ok := chatTabs[userJidStr]
|
||||||
if ok {
|
if ok {
|
||||||
str := *msg.CleanedBody
|
str := *msg.CleanedBody
|
||||||
@@ -474,6 +475,7 @@ func main() {
|
|||||||
if msg.Reply == nil {
|
if msg.Reply == nil {
|
||||||
replyID = "PICLIENT:UNAVAILABLE"
|
replyID = "PICLIENT:UNAVAILABLE"
|
||||||
} else {
|
} else {
|
||||||
|
fmt.Println("Received reply in DM")
|
||||||
replyID = msg.Reply.ID
|
replyID = msg.Reply.ID
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -500,16 +502,15 @@ func main() {
|
|||||||
|
|
||||||
tab.Messages = append(tab.Messages, myMessage)
|
tab.Messages = append(tab.Messages, myMessage)
|
||||||
fyne.Do(func() {
|
fyne.Do(func() {
|
||||||
UITabs[userJidStr].Scroller.Refresh()
|
//UITabs[userJidStr].Scroller.Refresh()
|
||||||
if scrollDownOnNewMessage {
|
if scrollDownOnNewMessage {
|
||||||
UITabs[userJidStr].Scroller.ScrollToBottom()
|
//UITabs[userJidStr].Scroller.ScrollToBottom()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
client.SetGroupChatHandler(func(client *oasisSdk.XmppClient, muc *muc.Channel, msg *oasisSdk.XMPPChatMessage) {
|
client.SetGroupChatHandler(func(client *oasisSdk.XmppClient, muc *muc.Channel, msg *oasisSdk.XMPPChatMessage) {
|
||||||
// HACK: IGNORING ALL MESSAGES FROM CLASSIC MUC HISTORY IN PREPARATION OF MAM SUPPORT
|
|
||||||
ignore := false
|
ignore := false
|
||||||
correction := false
|
correction := false
|
||||||
important := false
|
important := false
|
||||||
@@ -533,6 +534,8 @@ func main() {
|
|||||||
var ImageID string = ""
|
var ImageID string = ""
|
||||||
mucJidStr := msg.From.Bare().String()
|
mucJidStr := msg.From.Bare().String()
|
||||||
if tab, ok := chatTabs[mucJidStr]; ok {
|
if tab, ok := chatTabs[mucJidStr]; ok {
|
||||||
|
chatInfo.Objects[0] = widget.NewLabel(fmt.Sprintf("[!] %s", mucJidStr))
|
||||||
|
chatInfo.Refresh()
|
||||||
chatTabs[mucJidStr].Muc = muc
|
chatTabs[mucJidStr].Muc = muc
|
||||||
str := *msg.CleanedBody
|
str := *msg.CleanedBody
|
||||||
if strings.Contains(str, login.DisplayName) {
|
if strings.Contains(str, login.DisplayName) {
|
||||||
@@ -631,6 +634,8 @@ func main() {
|
|||||||
bareAcc := from.Bare()
|
bareAcc := from.Bare()
|
||||||
tab, ok := chatTabs[bareAcc.String()]
|
tab, ok := chatTabs[bareAcc.String()]
|
||||||
if !ok {
|
if !ok {
|
||||||
|
// User presence
|
||||||
|
addChatTab(false, bareAcc, client.Login.DisplayName)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -703,6 +708,17 @@ func main() {
|
|||||||
a = app.New()
|
a = app.New()
|
||||||
|
|
||||||
w = a.NewWindow("pi")
|
w = a.NewWindow("pi")
|
||||||
|
w.SetCloseIntercept(func() {
|
||||||
|
dialog.ShowConfirm("Close pi", "You hit the close button. Do you want Pi to close completely (confirm) or minimize to the tray? (cancel)", func(b bool) {
|
||||||
|
if b {
|
||||||
|
w.Close()
|
||||||
|
a.Quit()
|
||||||
|
log.Fatalln("Goodbye!")
|
||||||
|
} else {
|
||||||
|
w.Hide()
|
||||||
|
}
|
||||||
|
}, w)
|
||||||
|
})
|
||||||
w.Resize(fyne.NewSize(500, 500))
|
w.Resize(fyne.NewSize(500, 500))
|
||||||
|
|
||||||
entry := NewCustomMultiLineEntry()
|
entry := NewCustomMultiLineEntry()
|
||||||
@@ -763,6 +779,23 @@ func main() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
}, w)
|
}, w)
|
||||||
|
|
||||||
|
} else if text == "@here" && chatTabs[activeMucJid].isMuc {
|
||||||
|
tab := chatTabs[activeMucJid]
|
||||||
|
dialog.ShowConfirm("WARNING", fmt.Sprintf("There are %d members in this room.\nYou are about to mention every single one of them.\nYou may be punished if you are not a moderator of this chat.\nWould you like to continue?", len(tab.Members)), func(b bool) {
|
||||||
|
|
||||||
|
if b {
|
||||||
|
text = ""
|
||||||
|
for name := range tab.Members {
|
||||||
|
text = fmt.Sprintf("%s %s", text, jid.MustParse(name).Resourcepart())
|
||||||
|
}
|
||||||
|
|
||||||
|
err = client.SendText(jid.MustParse(activeMucJid).Bare(), text)
|
||||||
|
if err != nil {
|
||||||
|
dialog.ShowError(err, w)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, w)
|
||||||
} else {
|
} else {
|
||||||
err = client.SendText(jid.MustParse(activeMucJid).Bare(), text)
|
err = client.SendText(jid.MustParse(activeMucJid).Bare(), text)
|
||||||
|
|
||||||
@@ -1050,6 +1083,7 @@ func main() {
|
|||||||
AppTabs.Items[0].Content = myScroller
|
AppTabs.Items[0].Content = myScroller
|
||||||
AppTabs.Items[0].Text = "Bookmarks"
|
AppTabs.Items[0].Text = "Bookmarks"
|
||||||
AppTabs.SelectIndex(0)
|
AppTabs.SelectIndex(0)
|
||||||
|
chatSidebar.Hidden = true
|
||||||
//d := dialog.NewCustom("manage bookmarks", "cancel", myScroller, w)
|
//d := dialog.NewCustom("manage bookmarks", "cancel", myScroller, w)
|
||||||
//d.Show()
|
//d.Show()
|
||||||
|
|
||||||
@@ -1152,6 +1186,40 @@ func main() {
|
|||||||
entry.Text = old
|
entry.Text = old
|
||||||
})
|
})
|
||||||
|
|
||||||
|
kai := fyne.NewMenuItem("kai cenat beg", func() {
|
||||||
|
old := entry.Text
|
||||||
|
entry.Text = "chat will you subscribe to save the kai cenat mafiathon 3"
|
||||||
|
SendCallback()
|
||||||
|
entry.Text = old
|
||||||
|
})
|
||||||
|
|
||||||
|
mipipiemi := fyne.NewMenuItem("mi pipi e mi", func() {
|
||||||
|
old := entry.Text
|
||||||
|
entry.Text = "mi pipi e mi"
|
||||||
|
SendCallback()
|
||||||
|
entry.Text = old
|
||||||
|
})
|
||||||
|
|
||||||
|
exposed_suffix := fyne.NewMenuItem(".exposed", func() {
|
||||||
|
selectedScroller, ok := AppTabs.Selected().Content.(*widget.List)
|
||||||
|
if !ok {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var activeChatJid string
|
||||||
|
for jid, tabData := range UITabs {
|
||||||
|
if tabData.Scroller == selectedScroller {
|
||||||
|
activeChatJid = jid
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
LatestMessage := chatTabs[activeChatJid].Messages[len(chatTabs[activeChatJid].Messages)-1]
|
||||||
|
|
||||||
|
old := entry.Text
|
||||||
|
entry.Text = fmt.Sprintf("%s.exposed", LatestMessage.Content)
|
||||||
|
SendCallback()
|
||||||
|
entry.Text = old
|
||||||
|
})
|
||||||
|
|
||||||
mycurrenttime := fyne.NewMenuItem("Current time", func() {
|
mycurrenttime := fyne.NewMenuItem("Current time", func() {
|
||||||
entry.Text = fmt.Sprintf("It is currently %s", time.Now().Format(time.RFC850))
|
entry.Text = fmt.Sprintf("It is currently %s", time.Now().Format(time.RFC850))
|
||||||
SendCallback()
|
SendCallback()
|
||||||
@@ -1208,7 +1276,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
menu_jokes := fyne.NewMenu("Δ", mycurrenttime, hafjag, hotfuck, agree, mycurrentplayingsong)
|
menu_jokes := fyne.NewMenu("Δ", mycurrenttime, mycurrentplayingsong, hafjag, hotfuck, agree, kai, mipipiemi, exposed_suffix)
|
||||||
bit := fyne.NewMenuItem("mark selected message as read", func() {
|
bit := fyne.NewMenuItem("mark selected message as read", func() {
|
||||||
selectedScroller, ok := AppTabs.Selected().Content.(*widget.List)
|
selectedScroller, ok := AppTabs.Selected().Content.(*widget.List)
|
||||||
if !ok {
|
if !ok {
|
||||||
@@ -1299,7 +1367,7 @@ func main() {
|
|||||||
|
|
||||||
desk, ok := a.(desktop.App)
|
desk, ok := a.(desktop.App)
|
||||||
if ok {
|
if ok {
|
||||||
desk.SetSystemTrayMenu(menu_help)
|
desk.SetSystemTrayMenu(fyne.NewMenu("", fyne.NewMenuItem("show", w.Show)))
|
||||||
}
|
}
|
||||||
|
|
||||||
AppTabs = container.NewAppTabs(
|
AppTabs = container.NewAppTabs(
|
||||||
@@ -1307,7 +1375,7 @@ func main() {
|
|||||||
pi
|
pi
|
||||||
|
|
||||||
This tab will be used for displaying certain actions, such as
|
This tab will be used for displaying certain actions, such as
|
||||||
managing your bookmarks configuring rooms.
|
managing your bookmarks and configuring rooms.
|
||||||
`)),
|
`)),
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -1320,6 +1388,10 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
AppTabs.OnSelected = func(ti *container.TabItem) {
|
AppTabs.OnSelected = func(ti *container.TabItem) {
|
||||||
|
if AppTabs.Selected() == AppTabs.Items[0] {
|
||||||
|
chatSidebar.Hidden = true
|
||||||
|
return
|
||||||
|
}
|
||||||
selectedScroller, ok := AppTabs.Selected().Content.(*widget.List)
|
selectedScroller, ok := AppTabs.Selected().Content.(*widget.List)
|
||||||
if !ok {
|
if !ok {
|
||||||
return
|
return
|
||||||
@@ -1335,53 +1407,65 @@ func main() {
|
|||||||
|
|
||||||
tab := chatTabs[activeChatJid]
|
tab := chatTabs[activeChatJid]
|
||||||
UITab := UITabs[activeChatJid]
|
UITab := UITabs[activeChatJid]
|
||||||
if tab.isMuc {
|
|
||||||
//chatInfo = *container.NewHBox(widget.NewLabel(tab.Muc.Addr().String()))
|
|
||||||
} else {
|
|
||||||
chatInfo = *container.NewHBox(widget.NewLabel(tab.Jid.String()))
|
|
||||||
}
|
|
||||||
|
|
||||||
chatSidebar = *UITab.Sidebar
|
chatSidebar = *UITab.Sidebar
|
||||||
box := container.NewVBox(widget.NewRichTextFromMarkdown("# "+activeChatJid), widget.NewLabel(fmt.Sprintf("%d members ", len(tab.Members))))
|
if tab.isMuc {
|
||||||
chatSidebar.Objects = []fyne.CanvasObject{}
|
box := container.NewVBox(widget.NewRichTextFromMarkdown("# "+activeChatJid), widget.NewLabel(fmt.Sprintf("%d members ", len(tab.Members))))
|
||||||
|
chatSidebar.Objects = []fyne.CanvasObject{}
|
||||||
|
|
||||||
for name := range tab.Members {
|
for name, p := range tab.Members {
|
||||||
gen, _ := identicon.New("github", 5, 3)
|
gen, _ := identicon.New("github", 5, 3)
|
||||||
userjid, err := jid.Parse(name)
|
userjid, err := jid.Parse(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("ERROR: " + err.Error())
|
fmt.Println("ERROR: " + err.Error())
|
||||||
continue // unrecoverable
|
continue // unrecoverable
|
||||||
}
|
}
|
||||||
nickname := userjid.Resourcepart()
|
nickname := userjid.Resourcepart()
|
||||||
if nickname == "" {
|
if nickname == "" {
|
||||||
continue // we got the MUC presence, do not include it in the member list
|
continue // we got the MUC presence, do not include it in the member list
|
||||||
}
|
}
|
||||||
ii, err := gen.Draw(nickname)
|
ii, err := gen.Draw(nickname)
|
||||||
mention := func() {
|
mention := func() {
|
||||||
entry.SetText(fmt.Sprintf("%s %s", entry.Text, nickname))
|
entry.SetText(fmt.Sprintf("%s %s", entry.Text, nickname))
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("ERROR: " + err.Error())
|
fmt.Println("ERROR: " + err.Error())
|
||||||
box.Add(container.NewHBox(widget.NewLabel(nickname), widget.NewButton("Mention", mention)))
|
box.Add(container.NewHBox(widget.NewLabel(nickname), widget.NewButton("Mention", mention)))
|
||||||
} else {
|
} else {
|
||||||
im := ii.Image(25)
|
im := ii.Image(25)
|
||||||
imageWidget := canvas.NewImageFromImage(im)
|
imageWidget := canvas.NewImageFromImage(im)
|
||||||
imageWidget.FillMode = canvas.ImageFillOriginal
|
imageWidget.FillMode = canvas.ImageFillOriginal
|
||||||
imageWidget.Refresh()
|
imageWidget.Refresh()
|
||||||
nickLabel := widget.NewLabel(nickname)
|
nickLabel := widget.NewLabel(nickname)
|
||||||
nickLabel.Selectable = true
|
nickLabel.Selectable = true
|
||||||
box.Add(container.NewHBox(imageWidget, nickLabel))
|
|
||||||
}
|
|
||||||
|
|
||||||
|
box.Add(container.NewHBox(imageWidget, nickLabel))
|
||||||
|
if p.Status != "" {
|
||||||
|
s := widget.NewLabel(fmt.Sprintf("\"%s\"", p.Status))
|
||||||
|
s.Importance = widget.WarningImportance
|
||||||
|
s.TextStyle = fyne.TextStyle{
|
||||||
|
Bold: false,
|
||||||
|
Italic: true,
|
||||||
|
Monospace: false,
|
||||||
|
}
|
||||||
|
s.Truncation = fyne.TextTruncateEllipsis
|
||||||
|
box.Add(s)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
chatSidebar = *container.NewGridWithColumns(1, container.NewVScroll(box))
|
||||||
|
} else {
|
||||||
|
chatSidebar = *container.NewVBox(widget.NewRichTextFromMarkdown("# " + activeChatJid))
|
||||||
}
|
}
|
||||||
chatSidebar = *container.NewGridWithColumns(1, container.NewVScroll(box))
|
chatSidebar.Hidden = false
|
||||||
chatSidebar.Refresh()
|
chatSidebar.Refresh()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// HACK - disable chatsidebar because it's currently very buggy
|
|
||||||
chatSidebar.Hidden = false
|
chatSidebar.Hidden = false
|
||||||
statBar.SetText("")
|
statBar.SetText("")
|
||||||
|
chatInfo = *container.NewHBox(widget.NewLabel(""))
|
||||||
w.SetContent(container.NewVSplit(container.NewVSplit(container.NewHSplit(AppTabs, &chatSidebar), container.NewHSplit(entry, container.NewGridWithRows(1, sendbtn, replybtn))), container.NewHSplit(&statBar, &chatInfo)))
|
w.SetContent(container.NewVSplit(container.NewVSplit(container.NewHSplit(AppTabs, &chatSidebar), container.NewHSplit(entry, container.NewGridWithRows(1, sendbtn, replybtn))), container.NewHSplit(&statBar, &chatInfo)))
|
||||||
w.ShowAndRun()
|
w.ShowAndRun()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user