feat: saving person pass across logout/rejoin
This commit is contained in:
@@ -11,10 +11,12 @@ type Room struct {
|
||||
AdminIds []PersonId
|
||||
PasswordHash string
|
||||
CurrentSpeaker PersonId // i guess let's set to zero value when it's noone from the room
|
||||
Paricipants []Person
|
||||
// TODO hands, for each type of hand?
|
||||
// i guess participants order fixed for now?
|
||||
// and i'll still need 'current' for each hand level
|
||||
// all people that were visiting room before, spectating now or being a participant
|
||||
// used to check person password against the name
|
||||
AllKnownPeople []Person
|
||||
// person ids of people who are currently participating in the discussion at the table
|
||||
// TODO for now peson in seated at join and removed at logout in routes
|
||||
Paricipants []PersonId
|
||||
ParticipantHands map[PersonId]HandGesture
|
||||
Marks map[HandGesture]PersonId
|
||||
}
|
||||
@@ -68,9 +70,9 @@ gestureIteration:
|
||||
for i := 1; i < participantsCount; i++ {
|
||||
checkIndex := (startIndex + i) % participantsCount
|
||||
checkPerson := r.Paricipants[checkIndex]
|
||||
checkGesture, isFound := r.ParticipantHands[checkPerson.Id]
|
||||
checkGesture, isFound := r.ParticipantHands[checkPerson]
|
||||
if isFound && checkGesture == gesture {
|
||||
nextSpeakerId, nextSpeakerFound = checkPerson.Id, true
|
||||
nextSpeakerId, nextSpeakerFound = checkPerson, true
|
||||
break gestureIteration
|
||||
}
|
||||
}
|
||||
@@ -128,9 +130,7 @@ func (r *Room) gestureSearchStartIndex(gesture, curSpeakerGesture HandGesture) i
|
||||
log.Printf("> selecting person from which to start. cur speaker %s, for gestrue %s, got person %d",
|
||||
curSpeakerGesture.String(), gesture.String(), personFromWhichToStartSearch)
|
||||
|
||||
indexFromWhichToStart := slices.IndexFunc(r.Paricipants, func(p Person) bool {
|
||||
return p.Id == personFromWhichToStartSearch
|
||||
})
|
||||
indexFromWhichToStart := slices.Index(r.Paricipants, personFromWhichToStartSearch)
|
||||
return indexFromWhichToStart
|
||||
}
|
||||
|
||||
@@ -141,7 +141,7 @@ func (r *Room) Equal(other *Room) bool {
|
||||
if r.Name != other.Name || r.PasswordHash != other.PasswordHash || r.CurrentSpeaker != other.CurrentSpeaker {
|
||||
return false
|
||||
}
|
||||
if !slices.Equal(r.AdminIds, other.AdminIds) || !slices.Equal(r.Paricipants, other.Paricipants) {
|
||||
if !slices.Equal(r.AdminIds, other.AdminIds) || !slices.Equal(r.Paricipants, other.Paricipants) || !slices.Equal(r.AllKnownPeople, other.AllKnownPeople) {
|
||||
return false
|
||||
}
|
||||
if !maps.Equal(r.ParticipantHands, other.ParticipantHands) || !maps.Equal(r.Marks, other.Marks) {
|
||||
|
||||
@@ -55,7 +55,7 @@ var singleHandActive releaseHandTest = releaseHandTest{
|
||||
room: Room{
|
||||
Name: "test",
|
||||
CurrentSpeaker: person1.Id,
|
||||
Paricipants: []Person{
|
||||
AllKnownPeople: []Person{
|
||||
person1,
|
||||
person2,
|
||||
},
|
||||
@@ -67,7 +67,7 @@ var singleHandActive releaseHandTest = releaseHandTest{
|
||||
expected: Room{
|
||||
Name: "test",
|
||||
CurrentSpeaker: PersonId(0),
|
||||
Paricipants: []Person{
|
||||
AllKnownPeople: []Person{
|
||||
person1,
|
||||
person2,
|
||||
},
|
||||
@@ -81,10 +81,10 @@ var raisingLevelFromExpandToClarifyingQ releaseHandTest = releaseHandTest{
|
||||
room: Room{
|
||||
Name: "test",
|
||||
CurrentSpeaker: person1.Id,
|
||||
Paricipants: []Person{
|
||||
person1,
|
||||
person2,
|
||||
person3,
|
||||
Paricipants: []PersonId{
|
||||
person1.Id,
|
||||
person2.Id,
|
||||
person3.Id,
|
||||
},
|
||||
ParticipantHands: map[PersonId]HandGesture{
|
||||
person1.Id: Expand,
|
||||
@@ -95,10 +95,10 @@ var raisingLevelFromExpandToClarifyingQ releaseHandTest = releaseHandTest{
|
||||
expected: Room{
|
||||
Name: "test",
|
||||
CurrentSpeaker: person3.Id,
|
||||
Paricipants: []Person{
|
||||
person1,
|
||||
person2,
|
||||
person3,
|
||||
Paricipants: []PersonId{
|
||||
person1.Id,
|
||||
person2.Id,
|
||||
person3.Id,
|
||||
},
|
||||
ParticipantHands: map[PersonId]HandGesture{
|
||||
person3.Id: ClarifyingQ,
|
||||
@@ -115,10 +115,10 @@ var selectNextHigherLevel releaseHandTest = releaseHandTest{
|
||||
room: Room{
|
||||
Name: "test",
|
||||
CurrentSpeaker: person1.Id,
|
||||
Paricipants: []Person{
|
||||
person1,
|
||||
person2,
|
||||
person3,
|
||||
Paricipants: []PersonId{
|
||||
person1.Id,
|
||||
person2.Id,
|
||||
person3.Id,
|
||||
},
|
||||
ParticipantHands: map[PersonId]HandGesture{
|
||||
person1.Id: Meta,
|
||||
@@ -130,10 +130,10 @@ var selectNextHigherLevel releaseHandTest = releaseHandTest{
|
||||
expected: Room{
|
||||
Name: "test",
|
||||
CurrentSpeaker: person3.Id,
|
||||
Paricipants: []Person{
|
||||
person1,
|
||||
person2,
|
||||
person3,
|
||||
Paricipants: []PersonId{
|
||||
person1.Id,
|
||||
person2.Id,
|
||||
person3.Id,
|
||||
},
|
||||
ParticipantHands: map[PersonId]HandGesture{
|
||||
person2.Id: Expand,
|
||||
@@ -150,11 +150,11 @@ var usingMarkToLoverLevel releaseHandTest = releaseHandTest{
|
||||
room: Room{
|
||||
Name: "test",
|
||||
CurrentSpeaker: person3.Id,
|
||||
Paricipants: []Person{
|
||||
person1,
|
||||
person2,
|
||||
person3,
|
||||
person4,
|
||||
Paricipants: []PersonId{
|
||||
person1.Id,
|
||||
person2.Id,
|
||||
person3.Id,
|
||||
person4.Id,
|
||||
},
|
||||
ParticipantHands: map[PersonId]HandGesture{
|
||||
person2.Id: Expand,
|
||||
@@ -170,11 +170,11 @@ var usingMarkToLoverLevel releaseHandTest = releaseHandTest{
|
||||
expected: Room{
|
||||
Name: "test",
|
||||
CurrentSpeaker: person2.Id,
|
||||
Paricipants: []Person{
|
||||
person1,
|
||||
person2,
|
||||
person3,
|
||||
person4,
|
||||
Paricipants: []PersonId{
|
||||
person1.Id,
|
||||
person2.Id,
|
||||
person3.Id,
|
||||
person4.Id,
|
||||
},
|
||||
ParticipantHands: map[PersonId]HandGesture{
|
||||
person2.Id: Expand,
|
||||
@@ -191,11 +191,11 @@ var releasingNonSpeakerHand releaseHandTest = releaseHandTest{
|
||||
room: Room{
|
||||
Name: "test",
|
||||
CurrentSpeaker: person3.Id,
|
||||
Paricipants: []Person{
|
||||
person1,
|
||||
person2,
|
||||
person3,
|
||||
person4,
|
||||
Paricipants: []PersonId{
|
||||
person1.Id,
|
||||
person2.Id,
|
||||
person3.Id,
|
||||
person4.Id,
|
||||
},
|
||||
ParticipantHands: map[PersonId]HandGesture{
|
||||
person2.Id: Expand,
|
||||
@@ -211,11 +211,11 @@ var releasingNonSpeakerHand releaseHandTest = releaseHandTest{
|
||||
expected: Room{
|
||||
Name: "test",
|
||||
CurrentSpeaker: person3.Id,
|
||||
Paricipants: []Person{
|
||||
person1,
|
||||
person2,
|
||||
person3,
|
||||
person4,
|
||||
Paricipants: []PersonId{
|
||||
person1.Id,
|
||||
person2.Id,
|
||||
person3.Id,
|
||||
person4.Id,
|
||||
},
|
||||
ParticipantHands: map[PersonId]HandGesture{
|
||||
person2.Id: Expand,
|
||||
|
||||
Reference in New Issue
Block a user