feat: display room with current person in bottom

This commit is contained in:
efim 2023-11-19 05:57:30 +00:00
parent e4c56506be
commit af53bda10e
1 changed files with 5 additions and 2 deletions

View File

@ -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