diff options
author | delthas <delthas@dille.cc> | 2022-10-18 17:27:20 +0200 |
---|---|---|
committer | delthas <delthas@dille.cc> | 2022-10-18 17:30:43 +0200 |
commit | e4a2fe26415eba5cf7920c08acd0313b1c75d1f4 (patch) | |
tree | 0fc1f5d28a1dcb177ae9681eb9222280ae0a534e /commands.go | |
parent | Bump tcell version (diff) |
Clear highlights from MARKREAD when only NotifyNone lines are left
Previously, we did not clear buffers highlight statuses on MARKREAD if
there was any unread line after it.
This meant that if we received a plain message, than a join message, and
some other device sent us a read marker for the plain message, we would
still highlight the buffer. But we should not: a join message should not
highlight the buffer.
This is a recurrent use case because some clients do not display join
mesasges and therefore do not send read markers for it.
This updates the logic to actually store the notify level (in the line)
and uses it to reset the highlight status when only NotifyNone messages
(or no messages) are left.
Diffstat (limited to 'commands.go')
-rw-r--r-- | commands.go | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/commands.go b/commands.go index 9113485..132f914 100644 --- a/commands.go +++ b/commands.go @@ -198,7 +198,7 @@ func noCommand(app *App, content string) error { s.PrivMsg(buffer, content) if !s.HasCapability("echo-message") { - buffer, line, _ := app.formatMessage(s, irc.MessageEvent{ + buffer, line := app.formatMessage(s, irc.MessageEvent{ User: s.Nick(), Target: buffer, TargetIsChannel: s.IsChannel(buffer), @@ -206,7 +206,7 @@ func noCommand(app *App, content string) error { Content: content, Time: time.Now(), }) - app.win.AddLine(netID, buffer, ui.NotifyNone, line) + app.win.AddLine(netID, buffer, line) } return nil @@ -239,15 +239,15 @@ func commandDoHelp(app *App, args []string) (err error) { sb.SetStyle(tcell.StyleDefault) sb.WriteByte(' ') sb.WriteString(cmd.Usage) - app.win.AddLine(netID, buffer, ui.NotifyNone, ui.Line{ + app.win.AddLine(netID, buffer, ui.Line{ At: t, Body: sb.StyledString(), }) - app.win.AddLine(netID, buffer, ui.NotifyNone, ui.Line{ + app.win.AddLine(netID, buffer, ui.Line{ At: t, Body: ui.PlainSprintf(" %s", cmd.Desc), }) - app.win.AddLine(netID, buffer, ui.NotifyNone, ui.Line{ + app.win.AddLine(netID, buffer, ui.Line{ At: t, }) } @@ -261,7 +261,7 @@ func commandDoHelp(app *App, args []string) (err error) { } if len(args) == 0 { - app.win.AddLine(netID, buffer, ui.NotifyNone, ui.Line{ + app.win.AddLine(netID, buffer, ui.Line{ At: t, Head: "--", Body: ui.PlainString("Available commands:"), @@ -274,7 +274,7 @@ func commandDoHelp(app *App, args []string) (err error) { addLineCommands(cmdNames) } else { search := strings.ToUpper(args[0]) - app.win.AddLine(netID, buffer, ui.NotifyNone, ui.Line{ + app.win.AddLine(netID, buffer, ui.Line{ At: t, Head: "--", Body: ui.PlainSprintf("Commands that match \"%s\":", search), @@ -288,7 +288,7 @@ func commandDoHelp(app *App, args []string) (err error) { cmdNames = append(cmdNames, cmdName) } if len(cmdNames) == 0 { - app.win.AddLine(netID, buffer, ui.NotifyNone, ui.Line{ + app.win.AddLine(netID, buffer, ui.Line{ At: t, Body: ui.PlainSprintf(" no command matches %q", args[0]), }) @@ -326,7 +326,7 @@ func commandDoMe(app *App, args []string) (err error) { content := fmt.Sprintf("\x01ACTION %s\x01", args[0]) s.PrivMsg(buffer, content) if !s.HasCapability("echo-message") { - buffer, line, _ := app.formatMessage(s, irc.MessageEvent{ + buffer, line := app.formatMessage(s, irc.MessageEvent{ User: s.Nick(), Target: buffer, TargetIsChannel: s.IsChannel(buffer), @@ -334,7 +334,7 @@ func commandDoMe(app *App, args []string) (err error) { Content: content, Time: time.Now(), }) - app.win.AddLine(netID, buffer, ui.NotifyNone, line) + app.win.AddLine(netID, buffer, line) } return nil } @@ -368,7 +368,7 @@ func commandDoNames(app *App, args []string) (err error) { } body := sb.StyledString() // TODO remove last space - app.win.AddLine(netID, buffer, ui.NotifyNone, ui.Line{ + app.win.AddLine(netID, buffer, ui.Line{ At: time.Now(), Head: "--", HeadColor: tcell.ColorGray, @@ -491,7 +491,7 @@ func commandDoR(app *App, args []string) (err error) { } s.PrivMsg(app.lastQuery, args[0]) if !s.HasCapability("echo-message") { - buffer, line, _ := app.formatMessage(s, irc.MessageEvent{ + buffer, line := app.formatMessage(s, irc.MessageEvent{ User: s.Nick(), Target: app.lastQuery, TargetIsChannel: s.IsChannel(app.lastQuery), @@ -499,7 +499,7 @@ func commandDoR(app *App, args []string) (err error) { Content: args[0], Time: time.Now(), }) - app.win.AddLine(app.lastQueryNet, buffer, ui.NotifyNone, line) + app.win.AddLine(app.lastQueryNet, buffer, line) } return nil } @@ -696,7 +696,7 @@ func commandSendMessage(app *App, target string, content string) error { } s.PrivMsg(target, content) if !s.HasCapability("echo-message") { - buffer, line, _ := app.formatMessage(s, irc.MessageEvent{ + buffer, line := app.formatMessage(s, irc.MessageEvent{ User: s.Nick(), Target: target, TargetIsChannel: s.IsChannel(target), @@ -711,7 +711,7 @@ func commandSendMessage(app *App, target string, content string) error { app.win.AddBuffer(netID, "", buffer) } - app.win.AddLine(netID, buffer, ui.NotifyNone, line) + app.win.AddLine(netID, buffer, line) } return nil } |