ui: move direct messages item to top

This commit is contained in:
ayntgl 2022-03-25 22:35:25 +04:00
parent f9f61fdfe0
commit cb0f2ce803
2 changed files with 2 additions and 4 deletions

View file

@ -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) {

View file

@ -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
})