diff --git a/src/app/components/shared/_dialogs/topic-cloud-administration/topic-cloud-administration.component.ts b/src/app/components/shared/_dialogs/topic-cloud-administration/topic-cloud-administration.component.ts index 9d1bed55d7c8b9f4e0c0dd033baddfdf73d4db60..1961eff12146294186f77efcc563b4c5e20b2e78 100644 --- a/src/app/components/shared/_dialogs/topic-cloud-administration/topic-cloud-administration.component.ts +++ b/src/app/components/shared/_dialogs/topic-cloud-administration/topic-cloud-administration.component.ts @@ -169,6 +169,9 @@ export class TopicCloudAdministrationComponent implements OnInit, OnDestroy { initializeKeywords() { const roomId = localStorage.getItem('roomId'); this.roomDataService.getRoomData(roomId).subscribe(comments => { + if (comments === null) { + return; + } this.keywords = []; comments.forEach(comment => { this.pushInKeywords(comment); diff --git a/src/app/components/shared/comment-list/comment-list.component.ts b/src/app/components/shared/comment-list/comment-list.component.ts index 7c595d4335d5f03358c304ba95f5ffbbf33009ca..f7dade0e6c1ffe7e4bcf69cf1a7450fce534076f 100644 --- a/src/app/components/shared/comment-list/comment-list.component.ts +++ b/src/app/components/shared/comment-list/comment-list.component.ts @@ -251,6 +251,9 @@ export class CommentListComponent implements OnInit, OnDestroy { this.moderatorIds.push(this.room.ownerId); this.roomDataService.getRoomData(this.room.id).subscribe(comments => { + if (comments === null) { + return; + } this.comments = comments; this.getComments(); this.eventService.broadcast('commentListCreated', null); @@ -459,12 +462,14 @@ export class CommentListComponent implements OnInit, OnDestroy { pauseCommentStream() { this.freeze = true; - this.roomDataService.getRoomData(this.roomId, true) - .subscribe(comments => { - this.comments = comments; - this.setComments(comments); - this.getComments(); - }); + this.roomDataService.getRoomData(this.roomId, true).subscribe(comments => { + if (comments === null) { + return; + } + this.comments = comments; + this.setComments(comments); + this.getComments(); + }); this.commentStream.unsubscribe(); this.translateService.get('comment-list.comment-stream-stopped').subscribe(msg => { this.notificationService.show(msg); @@ -473,12 +478,14 @@ export class CommentListComponent implements OnInit, OnDestroy { playCommentStream() { this.freeze = false; - this.roomDataService.getRoomData(this.roomId) - .subscribe(comments => { - this.comments = comments; - this.setComments(comments); - this.getComments(); - }); + this.roomDataService.getRoomData(this.roomId).subscribe(comments => { + if (comments === null) { + return; + } + this.comments = comments; + this.setComments(comments); + this.getComments(); + }); this.subscribeCommentStream(); this.translateService.get('comment-list.comment-stream-started').subscribe(msg => { this.notificationService.show(msg); diff --git a/src/app/components/shared/questionwall/question-wall/question-wall.component.ts b/src/app/components/shared/questionwall/question-wall/question-wall.component.ts index f4f925129fa452e2389c1b3213f335b250a7e1eb..cc87e03cbce36f35d20c2c02577a0bc07455aea1 100644 --- a/src/app/components/shared/questionwall/question-wall/question-wall.component.ts +++ b/src/app/components/shared/questionwall/question-wall/question-wall.component.ts @@ -88,6 +88,9 @@ export class QuestionWallComponent implements OnInit, AfterViewInit, OnDestroy { QuestionWallComment.updateTimeFormat(localStorage.getItem('currentLang')); this.translateService.use(localStorage.getItem('currentLang')); this.roomDataService.getRoomData(this.roomId).subscribe(e => { + if (e === null) { + return; + } e.sort((a, b) => new Date(b.timestamp).getTime() - new Date(a.timestamp).getTime()); e.forEach(c => { this.roomDataService.checkProfanity(c); diff --git a/src/app/services/util/room-data.service.ts b/src/app/services/util/room-data.service.ts index 498e8c262c4ed96183595d7107d29987cf827212..f8f2c0f0f7fd72ce0d6b452780558249027371a5 100644 --- a/src/app/services/util/room-data.service.ts +++ b/src/app/services/util/room-data.service.ts @@ -1,5 +1,5 @@ import { Injectable } from '@angular/core'; -import { Observable, of, Subject, Subscription } from 'rxjs'; +import { BehaviorSubject, Observable, of, Subject, Subscription } from 'rxjs'; import { WsCommentService } from '../websockets/ws-comment.service'; import { Message } from '@stomp/stompjs'; import { Comment } from '../../models/comment'; @@ -88,7 +88,7 @@ export class RoomDataService { private _currentSubscriptions: RoomDataUpdateSubscription[] = []; private _currentComments: Comment[] = null; - private _commentUpdates: Subject<Comment[]> = new Subject<Comment[]>(); + private _commentUpdates: BehaviorSubject<Comment[]> = new BehaviorSubject<Comment[]>(null); private _fastCommentAccess: FastRoomAccessObject = null; private _wsCommentServiceSubscription: Subscription = null; private _currentRoomId: string = null; @@ -118,11 +118,11 @@ export class RoomDataService { } getRoomData(roomId: string, freezed: boolean = false): Observable<Comment[]> { - if (roomId && roomId === this._currentRoomId) { - return of(freezed ? [...this._currentComments] : this._currentComments); - } - const tempSubject = new Subject<Comment[]>(); + const tempSubject = new BehaviorSubject<Comment[]>(null); const subscription = this._commentUpdates.subscribe(comments => { + if (comments === null) { + return; + } tempSubject.next(freezed ? [...comments] : comments); subscription.unsubscribe(); }); diff --git a/src/app/services/util/tag-cloud-data.service.ts b/src/app/services/util/tag-cloud-data.service.ts index c3c3418f4fd06ecd44e7a9b2fa7e2feeb0ab67cc..97d22b273092bb8ee2b91de833ae9bdc6990e183 100644 --- a/src/app/services/util/tag-cloud-data.service.ts +++ b/src/app/services/util/tag-cloud-data.service.ts @@ -300,8 +300,13 @@ export class TagCloudDataService { } private fetchData(): void { + console.log('Try to get room data'); this._roomDataService.getRoomData(this._roomId).subscribe((comments: Comment[]) => { + if (comments === null) { + return; + } this._lastFetchedComments = comments; + console.log('Room data get', comments); this.rebuildTagData(); }); } @@ -322,9 +327,13 @@ export class TagCloudDataService { return; } const currentMeta = this._isDemoActive ? this._lastMetaData : this._currentMetaData; + console.log('Start filtering', this._currentFilter); const filteredComments = this._lastFetchedComments.filter(comment => this._currentFilter.checkComment(comment)); + console.log('End filtering', filteredComments); currentMeta.commentCount = filteredComments.length; + console.log('start building structure', this._adminData); const [data, users] = TagCloudDataService.buildDataFromComments(this._adminData, filteredComments); + console.log('end building structure', data); let minWeight = null; let maxWeight = null; for (const value of data.values()) {