Skip to content

Commit 630101e

Browse files
committed
Correct update of position in hand raise queue
1 parent 50711c3 commit 630101e

File tree

5 files changed

+46
-11
lines changed

5 files changed

+46
-11
lines changed

frontend/src/app/shared/components/popup/popup.component.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,4 @@ export class PopupComponent implements OnInit {
3030
this.letterColor = 'rgb(0, 0, 0)';
3131
}
3232
}
33-
3433
}

frontend/src/app/shared/components/toolbar/toolbar.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
<button mat-icon-button (click)="getInviteURL('participant')" *ngIf="localUser && this.userService.isModOfRoom(this.mySessionId)">
3838
<mat-icon matTooltip="Invite URL for participants">link</mat-icon>
3939
</button>
40-
<button mat-icon-button (click)="raiseHand()" *ngIf="localUser" id="raise_hand_button" matBadge="{{positionInHandRaiseQueue}}" [matBadgeHidden]="!localUser.isHandRaised()" matBadgePosition="below after" matBadgeSize="medium" matBadgeColor="warn">
40+
<button mat-icon-button (click)="raiseHand()" *ngIf="localUser" id="raise_hand_button" matBadge="{{localUser.getPositionInHandRaiseQueue()}}" [matBadgeHidden]="!localUser.isHandRaised()" matBadgePosition="below after" matBadgeSize="medium" matBadgeColor="warn">
4141
<img *ngIf="localUser && !localUser.isHandRaised()" src="../../../../assets/images/raise_hand.png" matTooltip="Raise your hand" id="raise_hand">
4242
<img *ngIf="localUser && localUser.isHandRaised()" src="../../../../assets/images/lower_hand.png" matTooltip="Lower your hand" id="raise_hand">
4343
</button>

frontend/src/app/shared/components/toolbar/toolbar.component.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import { MatSnackBar } from '@angular/material';
1313
})
1414
export class ToolbarComponent implements OnInit {
1515
fullscreenIcon = 'fullscreen';
16-
positionInHandRaiseQueue: number = 0;
1716

1817
@Input() lightTheme: boolean;
1918
@Input() mySessionId: string;
@@ -79,7 +78,7 @@ export class ToolbarComponent implements OnInit {
7978
if(!this.localUser.isHandRaised()) {
8079
this.roomSrv.raiseHand(this.mySessionId, this.localUser.getNickname(), this.localUser.getAvatar(), this.localUser.getConnectionId()).subscribe(
8180
position => {
82-
this.positionInHandRaiseQueue = position;
81+
this.localUser.setPositionInHandRaiseQueue(position);
8382
this.raiseHandClicked.emit();
8483
},
8584
error => console.error(error)
@@ -92,7 +91,6 @@ export class ToolbarComponent implements OnInit {
9291
error => console.error(error)
9392
);
9493
}
95-
9694
}
9795

9896
getInviteURL(role:string){

frontend/src/app/shared/models/user-model.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ export class UserModel {
3030
*/
3131
private handRaised: boolean;
3232

33+
/**
34+
* The position in the queue of people who are raising their hand (0 if not raising their hand)
35+
*/
36+
private positionInHandRaiseQueue: number;
37+
3338
/**
3439
* The user nickname
3540
*/
@@ -69,6 +74,7 @@ export class UserModel {
6974
this.videoActive = true;
7075
this.screenShareActive = false;
7176
this.handRaised = false;
77+
this.positionInHandRaiseQueue = 0;
7278
this.nickname = '';
7379
this.streamManager = null;
7480
this.type = 'local';
@@ -102,6 +108,13 @@ export class UserModel {
102108
return this.handRaised;
103109
}
104110

111+
/**
112+
* Return the position in the queue of people who are raising their hand (0 if not raising their hand)
113+
*/
114+
public getPositionInHandRaiseQueue(): number {
115+
return this.positionInHandRaiseQueue;
116+
}
117+
105118
/**
106119
* Return the connection ID
107120
*/
@@ -190,6 +203,14 @@ export class UserModel {
190203
this.handRaised = isHandRaised;
191204
}
192205

206+
/**
207+
* Set the position in the queue of people who are raising their hand
208+
* @param positionInHandRaiseQueue value of the position
209+
*/
210+
public setPositionInHandRaiseQueue(positionInHandRaiseQueue: number) {
211+
this.positionInHandRaiseQueue = positionInHandRaiseQueue;
212+
}
213+
193214
/**
194215
* Set the streamManager value object
195216
* @param streamManager value of streamManager

frontend/src/app/video-room/video-room.component.ts

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { ToolbarComponent } from './../shared/components/toolbar/toolbar.component';
12
import { RoomService } from './../shared/services/room.service';
23
import { AssistantsComponent } from './../shared/components/menu/assistants/assistants.component';
34
import { UserService } from '../shared/services/user.service';
@@ -24,7 +25,7 @@ import { ChatComponent } from '../shared/components/menu/chat/chat.component';
2425
import { OvSettings } from '../shared/models/ov-settings';
2526
import { ApiService } from '../shared/services/api.service';
2627
import { ThrowStmt } from '@angular/compiler';
27-
import { trigger, transition, style, animate, query, stagger, animateChild } from '@angular/animations';
28+
import { trigger, transition, style, animate } from '@angular/animations';
2829

2930
@Component({
3031
selector: 'app-video-room',
@@ -645,6 +646,9 @@ export class VideoRoomComponent implements OnInit, OnDestroy {
645646
if (data.isHandRaised !== undefined) {
646647
user.setHandRaised(data.isHandRaised);
647648
}
649+
if(data.positionInHandRaiseQueue !== undefined) {
650+
user.setPositionInHandRaiseQueue(data.positionInHandRaiseQueue);
651+
}
648652
}
649653
});
650654
this.remoteUsers.forEach((user: UserModel) => {
@@ -664,9 +668,15 @@ export class VideoRoomComponent implements OnInit, OnDestroy {
664668
if (data.avatar !== undefined) {
665669
user.setUserAvatar(data.avatar);
666670
}
671+
if(data.positionInHandRaiseQueue !== undefined) {
672+
user.setPositionInHandRaiseQueue(data.positionInHandRaiseQueue);
673+
}
667674
if (data.isHandRaised !== undefined) {
675+
const previousHandRaised = user.isHandRaised();
668676
user.setHandRaised(data.isHandRaised);
669-
this.raiseOrLowerHand(user);
677+
if(previousHandRaised!==user.isHandRaised()) {
678+
this.raiseOrLowerHand(user);
679+
}
670680
}
671681
if (data.isFirstTime) {
672682
this.showConnectionPopup(user.getNickname(), true, data.avatar);
@@ -678,7 +688,7 @@ export class VideoRoomComponent implements OnInit, OnDestroy {
678688
}
679689

680690
raiseOrLowerHand(user: UserModel) {
681-
if(user.isHandRaised()) {
691+
if(user.isHandRaised()) { //Raise the hand
682692
let unupdatedUser = this.handsRaised.filter(handRaisedUser => handRaisedUser.connectionId===user.getConnectionId())[0];
683693
if(unupdatedUser) { //Update the user that was already raising their hand
684694
const index = this.handsRaised.indexOf(unupdatedUser);
@@ -698,13 +708,17 @@ export class VideoRoomComponent implements OnInit, OnDestroy {
698708
this.recalculatePopupOffsets();
699709
}
700710
}
701-
} else {
711+
} else { //Lower the hand
702712
this.handsRaised = this.handsRaised.filter(handRaisedUser => handRaisedUser.connectionId!==user.getConnectionId());
703713
if(this.handsRaised.length==0) {
704714
setTimeout(() => {
705715
this.recalculatePopupOffsets();
706716
}, 500);
707717
}
718+
const localUserPosition = this.localUsers[0].getPositionInHandRaiseQueue();
719+
if(user.getPositionInHandRaiseQueue()<localUserPosition) {
720+
this.localUsers[0].setPositionInHandRaiseQueue(localUserPosition-1);
721+
}
708722
}
709723
this.handsRaisedMessage = (this.handsRaised.length>1 ? 'And ' + (this.handsRaised.length-1) + ' other ' + (this.handsRaised.length===2 ? 'person' : 'people') + ' are' : 'Is') + ' raising their hand'
710724
}
@@ -727,8 +741,10 @@ export class VideoRoomComponent implements OnInit, OnDestroy {
727741
}
728742
const connection = event.connection;
729743
const userDisconnected = this.remoteUsers.filter((user) => user.getConnectionId() === connection.connectionId)[0];
730-
userDisconnected.setHandRaised(false);
731-
this.raiseOrLowerHand(userDisconnected);
744+
if(userDisconnected.isHandRaised()) {
745+
userDisconnected.setHandRaised(false);
746+
this.raiseOrLowerHand(userDisconnected);
747+
}
732748
this.remoteUsers = this.remoteUsers.filter((user) => user.getConnectionId() !== connection.connectionId);
733749
this.showConnectionPopup(userDisconnected.getNickname(), false, userDisconnected.getAvatar());
734750
this.updateModConnections();
@@ -763,6 +779,7 @@ export class VideoRoomComponent implements OnInit, OnDestroy {
763779
isVideoActive: user.isVideoActive(),
764780
isScreenShareActive: user.isScreenShareActive(),
765781
isHandRaised: user.isHandRaised(),
782+
positionInHandRaiseQueue: user.getPositionInHandRaiseQueue(),
766783
nickname: user.getNickname(),
767784
avatar: user.getAvatar(),
768785
isFirstTime: isFirstTime,

0 commit comments

Comments
 (0)