mirror of https://github.com/OpenVidu/openvidu.git
openvidu-components: Fixed panel services bugs
Chat panel is not updating when a new message is received. Wrong method had been invokedpull/739/head
parent
556b3a0a2b
commit
ea3f16778e
|
@ -67,16 +67,6 @@ export class ChatPanelComponent implements OnInit, AfterViewInit {
|
||||||
*/
|
*/
|
||||||
constructor(private chatService: ChatService, private panelService: PanelService, private cd: ChangeDetectorRef) {}
|
constructor(private chatService: ChatService, private panelService: PanelService, private cd: ChangeDetectorRef) {}
|
||||||
|
|
||||||
/**
|
|
||||||
* @ignore
|
|
||||||
*/
|
|
||||||
@HostListener('document:keydown.escape', ['$event'])
|
|
||||||
onKeydownHandler(event: KeyboardEvent) {
|
|
||||||
if (this.panelService.isPanelOpened()) {
|
|
||||||
this.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.subscribeToMessages();
|
this.subscribeToMessages();
|
||||||
}
|
}
|
||||||
|
@ -125,7 +115,7 @@ export class ChatPanelComponent implements OnInit, AfterViewInit {
|
||||||
private subscribeToMessages() {
|
private subscribeToMessages() {
|
||||||
this.chatMessageSubscription = this.chatService.messagesObs.subscribe((messages: ChatMessage[]) => {
|
this.chatMessageSubscription = this.chatService.messagesObs.subscribe((messages: ChatMessage[]) => {
|
||||||
this.messageList = messages;
|
this.messageList = messages;
|
||||||
if (this.panelService.isPanelOpened()) {
|
if (this.panelService.isChatPanelOpened()) {
|
||||||
this.scrollToBottom();
|
this.scrollToBottom();
|
||||||
this.cd.markForCheck();
|
this.cd.markForCheck();
|
||||||
}
|
}
|
||||||
|
|
|
@ -590,7 +590,7 @@ export class ToolbarComponent implements OnInit, OnDestroy, AfterViewInit {
|
||||||
|
|
||||||
protected subscribeToChatMessages() {
|
protected subscribeToChatMessages() {
|
||||||
this.chatMessagesSubscription = this.chatService.messagesObs.pipe(skip(1)).subscribe((messages) => {
|
this.chatMessagesSubscription = this.chatService.messagesObs.pipe(skip(1)).subscribe((messages) => {
|
||||||
if (!this.panelService.isPanelOpened()) {
|
if (!this.panelService.isChatPanelOpened()) {
|
||||||
this.unreadMessages++;
|
this.unreadMessages++;
|
||||||
}
|
}
|
||||||
this.messageList = messages;
|
this.messageList = messages;
|
||||||
|
|
|
@ -50,7 +50,7 @@ export class ChatService {
|
||||||
nickname: data.nickname,
|
nickname: data.nickname,
|
||||||
message: data.message
|
message: data.message
|
||||||
});
|
});
|
||||||
if (!this.panelService.isPanelOpened()) {
|
if (!this.panelService.isChatPanelOpened()) {
|
||||||
const notificationOptions: INotificationOptions = {
|
const notificationOptions: INotificationOptions = {
|
||||||
message: `${data.nickname.toUpperCase()} sent a message`,
|
message: `${data.nickname.toUpperCase()} sent a message`,
|
||||||
cssClassName: 'messageSnackbar',
|
cssClassName: 'messageSnackbar',
|
||||||
|
|
|
@ -20,9 +20,6 @@ export class PanelService {
|
||||||
*/
|
*/
|
||||||
panelOpenedObs: Observable<PanelEvent>;
|
panelOpenedObs: Observable<PanelEvent>;
|
||||||
protected log: ILogger;
|
protected log: ILogger;
|
||||||
protected isChatOpened: boolean = false;
|
|
||||||
protected isParticipantsOpened: boolean = false;
|
|
||||||
protected isActivitiesOpened: boolean = false;
|
|
||||||
private isExternalOpened: boolean = false;
|
private isExternalOpened: boolean = false;
|
||||||
private externalType: string;
|
private externalType: string;
|
||||||
protected _panelOpened = <BehaviorSubject<PanelEvent>>new BehaviorSubject({ opened: false });
|
protected _panelOpened = <BehaviorSubject<PanelEvent>>new BehaviorSubject({ opened: false });
|
||||||
|
@ -59,10 +56,9 @@ export class PanelService {
|
||||||
} else {
|
} else {
|
||||||
// Panel is external
|
// Panel is external
|
||||||
this.log.d('Toggling external panel');
|
this.log.d('Toggling external panel');
|
||||||
this.isChatOpened = false;
|
// Close all panels
|
||||||
this.isParticipantsOpened = false;
|
this.panelMap.forEach((_, panel: string) => this.panelMap.set(panel, false));
|
||||||
this.isActivitiesOpened = false;
|
// Opening when external panel is closed or is opened with another type
|
||||||
// Open when is closed or is opened with another type
|
|
||||||
this.isExternalOpened = !this.isExternalOpened || this.externalType !== type;
|
this.isExternalOpened = !this.isExternalOpened || this.externalType !== type;
|
||||||
this.externalType = !this.isExternalOpened ? '' : type;
|
this.externalType = !this.isExternalOpened ? '' : type;
|
||||||
nextOpenedValue = this.isExternalOpened;
|
nextOpenedValue = this.isExternalOpened;
|
||||||
|
@ -76,19 +72,15 @@ export class PanelService {
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
isPanelOpened(): boolean {
|
isPanelOpened(): boolean {
|
||||||
return (
|
const anyOpened = Array.from(this.panelMap.values()).some((opened) => opened);
|
||||||
this.isChatPanelOpened() || this.isParticipantsPanelOpened() || this.isActivitiesPanelOpened() || this.isExternalPanelOpened()
|
return anyOpened || this.isExternalPanelOpened();
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Closes the panel (if opened)
|
* Closes the panel (if opened)
|
||||||
*/
|
*/
|
||||||
closePanel(): void {
|
closePanel(): void {
|
||||||
this.isParticipantsOpened = false;
|
this.panelMap.forEach((_, panel: string) => this.panelMap.set(panel, false));
|
||||||
this.isChatOpened = false;
|
|
||||||
this.isExternalOpened = false;
|
|
||||||
this.isActivitiesOpened = false;
|
|
||||||
this._panelOpened.next({ opened: false });
|
this._panelOpened.next({ opened: false });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,21 +88,35 @@ export class PanelService {
|
||||||
* Whether the chat panel is opened or not.
|
* Whether the chat panel is opened or not.
|
||||||
*/
|
*/
|
||||||
isChatPanelOpened(): boolean {
|
isChatPanelOpened(): boolean {
|
||||||
return this.isChatOpened;
|
return !!this.panelMap.get(PanelType.CHAT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether the participants panel is opened or not.
|
* Whether the participants panel is opened or not.
|
||||||
*/
|
*/
|
||||||
isParticipantsPanelOpened(): boolean {
|
isParticipantsPanelOpened(): boolean {
|
||||||
return this.isParticipantsOpened;
|
return !!this.panelMap.get(PanelType.PARTICIPANTS);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether the activities panel is opened or not.
|
* Whether the activities panel is opened or not.
|
||||||
*/
|
*/
|
||||||
isActivitiesPanelOpened(): boolean {
|
isActivitiesPanelOpened(): boolean {
|
||||||
return this.isActivitiesOpened;
|
return !!this.panelMap.get(PanelType.ACTIVITIES);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the settings panel is opened or not.
|
||||||
|
*/
|
||||||
|
isSettingsPanelOpened(): boolean {
|
||||||
|
return !!this.panelMap.get(PanelType.SETTINGS);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the background effects panel is opened or not.
|
||||||
|
*/
|
||||||
|
isBackgroundEffectsPanelOpened(): boolean {
|
||||||
|
return !!this.panelMap.get(PanelType.BACKGROUND_EFFECTS);
|
||||||
}
|
}
|
||||||
|
|
||||||
isExternalPanelOpened(): boolean {
|
isExternalPanelOpened(): boolean {
|
||||||
|
|
Loading…
Reference in New Issue