From 462331590c8929bc2f1eb6266c701ff319dd38c3 Mon Sep 17 00:00:00 2001 From: citrons Date: Mon, 9 Jun 2025 15:20:56 -0500 Subject: only open history view if message is not onscreen --- client/channel_window.go | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'client') diff --git a/client/channel_window.go b/client/channel_window.go index 3aed4c0..0e16af2 100644 --- a/client/channel_window.go +++ b/client/channel_window.go @@ -28,6 +28,7 @@ type channelWindow struct { endOfHistory bool startOfHistory bool jumpedTo buffer.Message + highlight string } type channelMsg struct { @@ -375,11 +376,23 @@ func (cw *channelWindow) ShowComposingReply() { } func (cw *channelWindow) OnNavigate() { + if cw.location.jumpTo != "" { + cw.highlight = cw.location.jumpTo + } if cw.jumpedTo != nil { cw.Buf.ScrollTo(cw.jumpedTo.Id()) } } +func (cw *channelWindow) goToMessage(id string) { + if tui.IsVisible("buffer." + id) { + cw.highlight = id + } else { + globalApp.goTo(channelLocation {id: cw.location.id, jumpTo: id}) + } +} + + func (m channelMsg) Id() string { return "buffer." + m.Object.Id } @@ -446,9 +459,7 @@ func (m channelMsg) showReply(bg int32, replyTo *proto.Object) { }) if replyTo != nil && mouse.Button == 0 && mouse.Pressed { - globalApp.goTo(channelLocation { - id: m.window.location.id, jumpTo: replyTo.Id, - }) + m.window.goToMessage(replyTo.Id) globalApp.redraw = true } @@ -485,7 +496,7 @@ func (m channelMsg) showReply(bg int32, replyTo *proto.Object) { func (m channelMsg) Show(odd bool) { var bg int32 = colorDefault[odd] - if m.Object.Id == m.window.location.jumpTo { + if m.Object.Id == m.window.highlight { bg = 17 } tui.Push("", tui.Box { -- cgit v1.2.3