From af53bda10e53be77fcbcf47d4c303acb6b176b45 Mon Sep 17 00:00:00 2001 From: efim Date: Sun, 19 Nov 2023 05:57:30 +0000 Subject: [PATCH] feat: display room with current person in bottom --- routes/room_page_templates_preview.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/routes/room_page_templates_preview.go b/routes/room_page_templates_preview.go index 8df202c..a314e09 100644 --- a/routes/room_page_templates_preview.go +++ b/routes/room_page_templates_preview.go @@ -40,10 +40,13 @@ type roomTableData struct { } func (room *roomTableData)Persons() []personData { - persons := make([]personData, 0, room.Total()) + total := room.Total() + persons := make([]personData, 0, total) + currentPersonIndex := slices.Index(room.Paricipants, room.currentPerson) for i, pId := range room.Paricipants { personData := personDataFromRoom(room, pId) - personData.Index = i + // to have index 0 for 'current person' + personData.Index = (i - currentPersonIndex + total) % total persons = append(persons, personData) } return persons