~edwargix/tallyard

0d1ebb3d8c41f2ea33bff8c7e30ce0f07f52a151 — David Florness 4 years ago eb2145e
Fix elections list update
1 files changed, 3 insertions(+), 9 deletions(-)

M ui/tui.go
M ui/tui.go => ui/tui.go +3 -9
@@ 80,20 80,14 @@ 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 {
			title := el.Title
			if title == "" {
				title = "<no name>"
			}
			var f func(string, string, rune, func()) *tview.List
			if i+1 < list.GetItemCount() {
				f = func(mainText string, secondaryText string, shortcut rune, selected func()) *tview.List {
					return list.InsertItem(i+1, mainText, secondaryText, shortcut, selected)
				}
			} else {
				f = list.AddItem
			}
			f(title, fmt.Sprintf("created by %s, ID: %s", el.Creator, el.CreateEventId), rune('a'+i), nil)
			list.AddItem(title, fmt.Sprintf("created by %s, ID: %s", el.Creator, el.CreateEventId), rune('a'+i), nil)
			i++
		}
	}