From 88b9bc32ff71c5cb7c8511be0fb9adcc5f522c1e Mon Sep 17 00:00:00 2001 From: erroneousboat Date: Sat, 7 Sep 2019 13:38:19 +0200 Subject: [PATCH] Only redraw grid when threads are present Reference #91 --- handlers/event.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/handlers/event.go b/handlers/event.go index 4922ef8..1f214b9 100644 --- a/handlers/event.go +++ b/handlers/event.go @@ -527,8 +527,19 @@ func actionChangeChannel(ctx *context.AppContext) { ctx.View.Channels.MarkAsRead(ctx.View.Channels.SelectedChannel) } - // Redraw grid, necessary when threads and/or debug is set - actionRedrawGrid(ctx, haveThreads, ctx.Debug) + // Redraw grid, necessary when threads and/or debug is set. We will redraw + // the grid when there are threads, or we just came from a thread and went + // to a channel without threads. Hence the clearing of ChannelItems of + // Threads. + if haveThreads { + actionRedrawGrid(ctx, haveThreads, ctx.Debug) + } else if !haveThreads && len(ctx.View.Threads.ChannelItems) > 0 { + ctx.View.Threads.SetChannels([]components.ChannelItem{}) + actionRedrawGrid(ctx, haveThreads, ctx.Debug) + } else { + termui.Render(ctx.View.Channels) + termui.Render(ctx.View.Chat) + } // Set focus, necessary to know when replying to thread or chat ctx.Focus = context.ChatFocus