Procházet zdrojové kódy

ui: move direct messages item to end

ayntgl před 4 roky
rodič
revize
172f369838
3 změnil soubory, kde provedl 13 přidání a 18 odebrání
  1. 9 9
      README.md
  2. 2 2
      ui/app.go
  3. 2 7
      ui/guilds.go

+ 9 - 9
README.md

@@ -30,15 +30,15 @@ Discordo is a lightweight, secure, and feature-rich Discord terminal client. Hea
 
 ### Roadmap
 
-- [] Mentions (autocompletion & suggestions)
-- [] Attachments
-- [] Typing indicator
-- [] Scripting interface
-- [] Threads
-- [] Members sidebar
-- [] Search/filter messages
-- [] User profile
-- [] Settings widgets
+- [ ] Mentions (autocompletion & suggestions)
+- [ ] Attachments
+- [ ] Typing indicator
+- [ ] Scripting interface
+- [ ] Threads
+- [ ] Members sidebar
+- [ ] Search/filter messages
+- [ ] User profile
+- [ ] Settings widgets
 
 ## Installation
 

+ 2 - 2
ui/app.go

@@ -110,8 +110,6 @@ func (app *App) DrawMainFlex() {
 }
 
 func (app *App) onSessionReady(_ *discordgo.Session, r *discordgo.Ready) {
-	app.GuildsList.AddItem("Direct Messages", "", 0, nil)
-
 	sort.Slice(r.Guilds, func(a, b int) bool {
 		found := false
 		for _, guildID := range r.Settings.GuildPositions {
@@ -129,6 +127,8 @@ func (app *App) onSessionReady(_ *discordgo.Session, r *discordgo.Ready) {
 	for _, g := range r.Guilds {
 		app.GuildsList.AddItem(g.Name, "", 0, nil)
 	}
+
+	app.GuildsList.AddItem("Direct Messages", "", 0, nil)
 }
 
 func (app *App) onSessionGuildCreate(_ *discordgo.Session, g *discordgo.GuildCreate) {

+ 2 - 7
ui/guilds.go

@@ -37,12 +37,7 @@ func (gl *GuildsList) onSelected(idx int, mainText string, secondaryText string,
 		Clear()
 	gl.app.MessageInputField.SetText("")
 
-	// If the user is a bot account, the direct messages item does not exist in the guilds list.
-	if gl.app.Session.State.User.Bot && idx == 0 {
-		idx = 1
-	}
-
-	if idx == 0 { // Direct Messages
+	if mainText == "Direct Messages" {
 		cs := gl.app.Session.State.PrivateChannels
 		sort.Slice(cs, func(i, j int) bool {
 			return cs[i].LastMessageID > cs[j].LastMessageID
@@ -54,7 +49,7 @@ func (gl *GuildsList) onSelected(idx int, mainText string, secondaryText string,
 			rootTreeNode.AddChild(channelTreeNode)
 		}
 	} else { // Guild
-		cs := gl.app.Session.State.Guilds[idx-1].Channels
+		cs := gl.app.Session.State.Guilds[idx].Channels
 		sort.Slice(cs, func(i, j int) bool {
 			return cs[i].Position < cs[j].Position
 		})