~edwargix/tallyard

cb7bccf2f0e71b547cf4bcc829b91eeddd1cbc33 — David Florness 4 years ago 19a4a11
Stop using shortcuts for room/election TUI lists

This is kind of a silly feature for dynamic lists that grow large.
1 files changed, 6 insertions(+), 7 deletions(-)

M ui/tui.go
M ui/tui.go => ui/tui.go +6 -7
@@ 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 = "<no name>"
			}
			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() {