From 0d1ebb3d8c41f2ea33bff8c7e30ce0f07f52a151 Mon Sep 17 00:00:00 2001 From: David Florness Date: Sat, 23 Jan 2021 20:23:44 -0500 Subject: [PATCH] Fix elections list update --- ui/tui.go | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/ui/tui.go b/ui/tui.go index b69bf10..f62e0d3 100644 --- a/ui/tui.go +++ b/ui/tui.go @@ -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 = "" } - 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++ } } -- 2.38.4