forked from sunglocto/pi-im
Modify corrected message appearance and make notification text less insane
This commit is contained in:
30
main.go
30
main.go
@@ -28,6 +28,7 @@ import (
|
||||
"fyne.io/fyne/v2/storage"
|
||||
"fyne.io/fyne/v2/theme"
|
||||
"fyne.io/fyne/v2/widget"
|
||||
"fyne.io/fyne/v2/layout"
|
||||
"github.com/gen2brain/beeep"
|
||||
"github.com/makeworld-the-better-one/go-isemoji"
|
||||
"github.com/rrivera/identicon"
|
||||
@@ -67,6 +68,7 @@ type Message struct {
|
||||
ID string
|
||||
ReplyID string
|
||||
ImageURL string
|
||||
Corrected bool
|
||||
Raw oasisSdk.XMPPChatMessage
|
||||
Important bool
|
||||
Readers []jid.JID
|
||||
@@ -192,7 +194,10 @@ func CreateUITab(chatJidStr string) ChatTabUI {
|
||||
|
||||
reactions := container.NewHBox()
|
||||
|
||||
return container.NewVBox(replytext, container.NewHBox(ico, author), content, btn, reactions)
|
||||
pencil := widget.NewButtonWithIcon("", theme.DocumentCreateIcon(), func(){})
|
||||
pencil.Hidden = true
|
||||
|
||||
return container.NewVBox(replytext, container.NewHBox(ico, author, layout.NewSpacer(), pencil), content, btn, reactions)
|
||||
},
|
||||
func(i widget.ListItemID, co fyne.CanvasObject) {
|
||||
|
||||
@@ -208,6 +213,8 @@ func CreateUITab(chatJidStr string) ChatTabUI {
|
||||
authorBox.Objects[0].(*canvas.Image).FillMode = canvas.ImageFillOriginal
|
||||
authorBox.Objects[0].Refresh()
|
||||
|
||||
pencil := authorBox.Objects[3].(*widget.Button)
|
||||
|
||||
// Icon generate end
|
||||
|
||||
author := authorBox.Objects[1].(*canvas.Text)
|
||||
@@ -246,6 +253,17 @@ func CreateUITab(chatJidStr string) ChatTabUI {
|
||||
} else {
|
||||
content.Importance = widget.MediumImportance
|
||||
}
|
||||
|
||||
if chatTabs[chatJidStr].Messages[i].Corrected {
|
||||
pencil.Hidden = false
|
||||
pencil.OnTapped = func() {
|
||||
dialog.ShowInformation("Original", *chatTabs[chatJidStr].Messages[i].Raw.CleanedBody, w)
|
||||
}
|
||||
} else {
|
||||
pencil.Hidden = true
|
||||
}
|
||||
|
||||
|
||||
btn.Hidden = true // Hide by default
|
||||
msgContent := chatTabs[chatJidStr].Messages[i].Content
|
||||
if chatTabs[chatJidStr].Messages[i].Raw.OutOfBandMedia != nil {
|
||||
@@ -548,7 +566,9 @@ func main() {
|
||||
if correction {
|
||||
for i := len(tab.Messages) - 1; i > 0; i-- {
|
||||
if tab.Messages[i].Raw.From.String() == msg.From.String() {
|
||||
tab.Messages[i].Content = *msg.CleanedBody + " (corrected)"
|
||||
// tab.Messages[i].Content = *msg.CleanedBody + " (corrected)"
|
||||
tab.Messages[i].Content = *msg.CleanedBody
|
||||
tab.Messages[i].Corrected = true
|
||||
fyne.Do(func() {
|
||||
UITabs[userJidStr].Scroller.Refresh()
|
||||
})
|
||||
@@ -617,7 +637,7 @@ func main() {
|
||||
if !donotnotify && !ignore && notifications {
|
||||
if !correction && msg.From.String() != client.JID.String() && strings.Contains(str, login.DisplayName) || (msg.Reply != nil && strings.Contains(msg.Reply.To, login.DisplayName)) {
|
||||
// a.SendNotification(fyne.NewNotification(fmt.Sprintf("Mentioned in %s", mucJidStr), str))
|
||||
beeep.Notify(fmt.Sprintf("Mentioned in %s by %s", mucJidStr, msg.From.Resourcepart()), str, iconBytes)
|
||||
beeep.Notify(fmt.Sprintf("Mentioned in %s by %s", jid.MustParse(mucJidStr).Localpart(), msg.From.Resourcepart()), str, iconBytes)
|
||||
}
|
||||
}
|
||||
if strings.Contains(str, "https://") {
|
||||
@@ -658,7 +678,9 @@ func main() {
|
||||
if correction {
|
||||
for i := len(tab.Messages) - 1; i > 0; i-- {
|
||||
if tab.Messages[i].Raw.From.String() == msg.From.String() {
|
||||
tab.Messages[i].Content = *msg.CleanedBody + " (corrected)"
|
||||
// tab.Messages[i].Content = *msg.CleanedBody + " (corrected)"
|
||||
tab.Messages[i].Content = *msg.CleanedBody
|
||||
tab.Messages[i].Corrected = true
|
||||
fyne.Do(func() {
|
||||
UITabs[mucJidStr].Scroller.Refresh()
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user