From d45ed575721b5e80a7e568fb15fb972476a2c922 Mon Sep 17 00:00:00 2001 From: sunglocto Date: Thu, 4 Sep 2025 18:11:37 +0100 Subject: [PATCH] refactor --- main.go | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/main.go b/main.go index 7be651b..bcbca65 100644 --- a/main.go +++ b/main.go @@ -86,6 +86,10 @@ func isUTF8Locale() bool { return false } +func isWindows() bool { + return os.PathSeparator == '\\' && os.PathListSeparator == ';' +} + func NewCustomMultiLineEntry() *CustomMultiLineEntry { entry := &CustomMultiLineEntry{} entry.ExtendBaseWidget(entry) @@ -200,7 +204,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 TODO: Fix highlighting messages with mentions, it's currently broken + content.Importance = widget.DangerImportance } btn.Hidden = true // Hide by default msgContent := chatTabs[chatJidStr].Messages[i].Content @@ -537,7 +541,7 @@ func main() { chatTabs[mucJidStr].Muc = muc str := *msg.CleanedBody if strings.Contains(str, login.DisplayName) { - fmt.Println(str) + fmt.Println(str, login.DisplayName) important = true } if !donotnotify && !ignore && notifications { @@ -560,9 +564,7 @@ func main() { lines[i] = strings.Join(s, " ") } str = strings.Join(lines, " ") - fmt.Println(str) } - fmt.Println(msg.ID) var replyID string if msg.Reply == nil { replyID = "PICLIENT:UNAVAILABLE" @@ -637,7 +639,6 @@ func main() { func(_ *oasisSdk.XmppClient, from jid.JID, id string) { for _, tab := range chatTabs { for i := len(tab.Messages) - 1; i >= 0; i-- { - fmt.Println(tab.Messages[i]) if tab.Messages[i].Raw.StanzaID == nil { continue } @@ -647,7 +648,6 @@ func main() { } } } - fmt.Printf("%s has seen %s\n", from.String(), id) }) if err != nil { @@ -709,7 +709,6 @@ func main() { go func() { if replying { m := chatTabs[activeMucJid].Messages[selectedId].Raw - fmt.Println(selectedId) err = client.ReplyToEvent(&m, text) if err != nil { dialog.ShowError(err, w) @@ -808,14 +807,6 @@ func main() { }, w) }) - mis := fyne.NewMenuItem("clear chat window", func() { - dialog.ShowConfirm("clear chat window", "are you sure you want to clear the chat window?", func(b bool) { - if b { - fmt.Println("clearing chat") - } - }, w) - }) - jtb := fyne.NewMenuItem("jump to bottom", func() { selectedScroller, ok := AppTabs.Selected().Content.(*widget.List) if !ok { @@ -1107,7 +1098,7 @@ func main() { menu_help := fyne.NewMenu("π", mit, reconnect, licensesbtn, savedata) menu_changeroom := fyne.NewMenu("Α", mic, beginADM, joinARoom, leaveRoom, jbookmarks) - menu_configureview := fyne.NewMenu("Β", mia, mis, jtt, jtb) + menu_configureview := fyne.NewMenu("Β", mia, jtt, jtb) hafjag := fyne.NewMenuItem("Hafjag", func() { entry.Text = "Hafjag" SendCallback() @@ -1146,7 +1137,7 @@ func main() { mycurrentplayingsong := fyne.NewMenuItem("Get currently playing song", func() { // BEGIN PLATFORM SPECIFIC CODE - if os.PathSeparator == '\\' && os.PathListSeparator == ';' { // Windows + if isWindows() { dialog.ShowError(errors.New("This feature is not supported on your operating system"), w) return }