From cb0f2ce803488701978fbb7cb89655c297ec265e Mon Sep 17 00:00:00 2001 From: ayntgl Date: Fri, 25 Mar 2022 22:35:25 +0400 Subject: [PATCH] ui: move direct messages item to top --- ui/app.go | 3 --- ui/guilds.go | 3 ++- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/ui/app.go b/ui/app.go index e8e290a..e206966 100644 --- a/ui/app.go +++ b/ui/app.go @@ -60,7 +60,6 @@ func (app *App) Connect() error { app.Session.AddHandler(app.onSessionGuildCreate) app.Session.AddHandler(app.onSessionMessageCreate) - return app.Session.Open() } @@ -123,8 +122,6 @@ func (app *App) onSessionReady(_ *astatine.Session, r *astatine.Ready) { for _, g := range r.Guilds { app.GuildsList.AddItem(g.Name, "", 0, nil) } - - app.GuildsList.AddItem("Direct Messages", "", 0, nil) } func (app *App) onSessionGuildCreate(_ *astatine.Session, g *astatine.GuildCreate) { diff --git a/ui/guilds.go b/ui/guilds.go index 5d406c5..a9c928b 100644 --- a/ui/guilds.go +++ b/ui/guilds.go @@ -19,6 +19,7 @@ func NewGuildsList(app *App) *GuildsList { app: app, } + gl.AddItem("Direct Messages", "", 0, nil) gl.ShowSecondaryText(false) gl.SetTitle("Guilds") gl.SetTitleAlign(tview.AlignLeft) @@ -49,7 +50,7 @@ func (gl *GuildsList) onSelected(idx int, mainText string, secondaryText string, rootTreeNode.AddChild(channelTreeNode) } } else { // Guild - cs := gl.app.Session.State.Guilds[idx].Channels + cs := gl.app.Session.State.Guilds[idx-1].Channels sort.Slice(cs, func(i, j int) bool { return cs[i].Position < cs[j].Position })