From cb7bccf2f0e71b547cf4bcc829b91eeddd1cbc33 Mon Sep 17 00:00:00 2001 From: David Florness Date: Sun, 31 Jan 2021 12:27:16 -0500 Subject: [PATCH] Stop using shortcuts for room/election TUI lists This is kind of a silly feature for dynamic lists that grow large. --- ui/tui.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/ui/tui.go b/ui/tui.go index 8764e00..e3a0ea4 100644 --- a/ui/tui.go +++ b/ui/tui.go @@ -27,7 +27,7 @@ func TUI(client *mautrix.Client, elections *election.ElectionsMap) (el *election } list := tview.NewList() list.SetTitle("Select a room").SetBorder(true) - for i, roomID := range resp.JoinedRooms { + for _, roomID := range resp.JoinedRooms { name := string(roomID) room := client.Store.LoadRoom(roomID) if room != nil { @@ -35,7 +35,7 @@ func TUI(client *mautrix.Client, elections *election.ElectionsMap) (el *election name = roomNameEvent.Content.AsRoomName().Name } } - list.AddItem(name, string(roomID), rune('a'+i), nil) + list.AddItem(name, string(roomID), 0, nil) } update := func() { for i, roomID := range resp.JoinedRooms { @@ -70,7 +70,7 @@ func RoomTUI(client *mautrix.Client, roomID id.RoomID, elections *election.Elect alive := true app := tview.NewApplication() list := tview.NewList(). - AddItem("Create Election", "start a new election in this room", '+', nil) + AddItem("Create Election", "start a new election in this room", 0, nil) list.SetTitle("Select election").SetBorder(true) var L []*election.Election var Ltime time.Time = elections.Ltime.Add(-1 * time.Millisecond) @@ -83,14 +83,13 @@ func RoomTUI(client *mautrix.Client, roomID id.RoomID, elections *election.Elect L = elections.L[roomID] Ltime = elections.Ltime list.Clear() - list.AddItem("Create Election", "start a new election in this room", '+', nil) - for i, el := range L { + list.AddItem("Create Election", "start a new election in this room", 0, nil) + for _, el := range L { title := el.Title if title == "" { title = "" } - list.AddItem(title, fmt.Sprintf("created by %s, ID: %s", el.Creator, el.CreateEventId), rune('a'+i), nil) - i++ + list.AddItem(title, fmt.Sprintf("created by %s, ID: %s", el.Creator, el.CreateEventId), 0, nil) } } go func() { -- 2.38.4