fix: remove all marks when noone speaks next
if room comes to a state where last person stopped speaking, then setting room to clean state is logical, next person to start speaking is the only reference point
This commit is contained in:
parent
acd9f4fc62
commit
ea85460c0a
|
@ -53,6 +53,7 @@ func (r *Room) RaiseHand(p PersonId, gesture HandGesture) Room {
|
|||
// - we should find next speaker
|
||||
// - assign room.CurrentSpeaker to next speaker or to PersonId(0) to indicate that noone is speaking
|
||||
// - if next speaker has gesture of higher priority - set Mark to current speaker for their gesture level
|
||||
// when there is not next speaker, remove all marks
|
||||
func (r *Room) ReleaseHand(p PersonId) {
|
||||
// releasing a hand of a current speaker should result in selection of a new speaker
|
||||
log.Printf("about to release hand of %d in %+v", p, r)
|
||||
|
@ -76,6 +77,7 @@ func (r *Room) ReleaseHand(p PersonId) {
|
|||
if !nextSpeakerFound {
|
||||
log.Printf("there is not next speaker, that's ok")
|
||||
r.CurrentSpeaker = PersonId(0)
|
||||
r.Marks = make(map[HandGesture]PersonId)
|
||||
} else {
|
||||
// searching for the next speaker
|
||||
currentSpeakerGesture := handReleaseGesture
|
||||
|
|
|
@ -20,6 +20,7 @@ var releaseHandTests = []releaseHandTest{
|
|||
releasingNonSpeakerHand,
|
||||
releaseToPersonWithHandAndMark,
|
||||
raisingLevelSetMarksWithoutOverridingExisting,
|
||||
releaseAllMarksWhenNoSpeaker,
|
||||
}
|
||||
|
||||
func TestRoomReleaseHand(t *testing.T) {
|
||||
|
@ -314,3 +315,40 @@ var releaseToPersonWithHandAndMark releaseHandTest = releaseHandTest{
|
|||
Marks: map[HandGesture]PersonId{},
|
||||
},
|
||||
}
|
||||
|
||||
// there is a mark for Expand on person 2, mark for Change Topic on person 3
|
||||
// speaker is person 1 with Expand
|
||||
// after hand release person nobody should be speaking, with all marks removed
|
||||
var releaseAllMarksWhenNoSpeaker releaseHandTest = releaseHandTest{
|
||||
testName: "releaseAllMarksWhenNoSpeaker",
|
||||
room: Room{
|
||||
Name: "test",
|
||||
CurrentSpeaker: person1.Id,
|
||||
Paricipants: []PersonId{
|
||||
person1.Id,
|
||||
person2.Id,
|
||||
person3.Id,
|
||||
person4.Id,
|
||||
},
|
||||
ParticipantHands: map[PersonId]HandGesture{
|
||||
person1.Id: Expand,
|
||||
},
|
||||
Marks: map[HandGesture]PersonId{
|
||||
Expand: person2.Id,
|
||||
ChangeTopic: person3.Id,
|
||||
},
|
||||
},
|
||||
releasingParticipantId: person1.Id,
|
||||
expected: Room{
|
||||
Name: "test",
|
||||
CurrentSpeaker: PersonId(0),
|
||||
Paricipants: []PersonId{
|
||||
person1.Id,
|
||||
person2.Id,
|
||||
person3.Id,
|
||||
person4.Id,
|
||||
},
|
||||
ParticipantHands: map[PersonId]HandGesture{},
|
||||
Marks: map[HandGesture]PersonId{},
|
||||
},
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue