Skip to content
Snippets Groups Projects
Commit 3be7e0ae authored by Tom Käsler's avatar Tom Käsler
Browse files

Merge branch 'unsub' into 'master'

Unsubscribe from stomp subscriptions

Closes #79

See merge request arsnova/frag.jetzt!216
parents de8dd1ef 17a5d6af
Branches
Tags
No related merge requests found
......@@ -37,8 +37,6 @@ export class RoomCreatorPageComponent extends RoomPageComponent implements OnIni
moderatorCommentCounter: number;
urlToCopy = 'https://frag.jetzt/participant/room/';
listenerFn: () => void;
constructor(protected roomService: RoomService,
protected notification: NotificationService,
protected route: ActivatedRoute,
......@@ -51,7 +49,7 @@ export class RoomCreatorPageComponent extends RoomPageComponent implements OnIni
private liveAnnouncer: LiveAnnouncer,
private _r: Renderer2,
public eventService: EventService) {
super(roomService, route, location, wsCommentService, commentService);
super(roomService, route, location, wsCommentService, commentService, eventService);
langService.langEmitter.subscribe(lang => translateService.use(lang));
}
......@@ -89,11 +87,6 @@ export class RoomCreatorPageComponent extends RoomPageComponent implements OnIni
});
}
ngOnDestroy() {
this.listenerFn();
this.eventService.makeFocusOnInputFalse();
}
public announce() {
this.liveAnnouncer.clear();
this.liveAnnouncer.announce('Du befindest dich in der von dir erstellten Sitzung. ' +
......
......@@ -28,8 +28,6 @@ export class RoomModeratorPageComponent extends RoomPageComponent implements OnI
moderatorCommentCounter: number;
viewModuleCount = 1;
listenerFn: () => void;
constructor(protected location: Location,
protected roomService: RoomService,
protected route: ActivatedRoute,
......@@ -41,7 +39,7 @@ export class RoomModeratorPageComponent extends RoomPageComponent implements OnI
public eventService: EventService,
private liveAnnouncer: LiveAnnouncer,
private _r: Renderer2) {
super(roomService, route, location, wsCommentService, commentService);
super(roomService, route, location, wsCommentService, commentService, eventService);
langService.langEmitter.subscribe(lang => translateService.use(lang));
}
......@@ -64,7 +62,8 @@ export class RoomModeratorPageComponent extends RoomPageComponent implements OnI
});
}
this.wsCommentService.getCommentStream(this.room.id).subscribe((message: Message) => {
this.commentWatch = this.wsCommentService.getCommentStream(this.room.id);
this.sub = this.commentWatch.subscribe((message: Message) => {
const msg = JSON.parse(message.body);
const payload = msg.payload;
if (msg.type === 'CommentCreated') {
......@@ -123,11 +122,6 @@ export class RoomModeratorPageComponent extends RoomPageComponent implements OnI
});
}
ngOnDestroy() {
this.listenerFn();
this.eventService.makeFocusOnInputFalse();
}
public announce() {
this.liveAnnouncer.announce('Du befindest dich in der Sitzung in der du als Moderator gewählt wurdest. ' +
'Drücke die Taste 1 um auf die Fragen-Übersicht zu gelangen, ' +
......
......@@ -28,8 +28,6 @@ export class RoomParticipantPageComponent extends RoomPageComponent implements O
deviceType = localStorage.getItem('deviceType');
user: User;
listenerFn: () => void;
constructor(protected location: Location,
protected roomService: RoomService,
protected route: ActivatedRoute,
......@@ -41,7 +39,7 @@ export class RoomParticipantPageComponent extends RoomPageComponent implements O
private liveAnnouncer: LiveAnnouncer,
private _r: Renderer2,
public eventService: EventService) {
super(roomService, route, location, wsCommentService, commentService);
super(roomService, route, location, wsCommentService, commentService, eventService);
langService.langEmitter.subscribe(lang => translateService.use(lang));
}
......@@ -74,11 +72,6 @@ export class RoomParticipantPageComponent extends RoomPageComponent implements O
});
}
ngOnDestroy() {
this.listenerFn();
this.eventService.makeFocusOnInputFalse();
}
public announce() {
this.liveAnnouncer.clear();
this.liveAnnouncer.announce('Du befindest dich in der Sitzung mit dem von dir eingegebenen Sitzungs-Code. ' +
......
import { Component, ElementRef, Input, OnInit, ViewChild } from '@angular/core';
import { Component, ElementRef, Input, OnInit, OnDestroy, ViewChild } from '@angular/core';
import { Comment } from '../../../models/comment';
import { CommentService } from '../../../services/http/comment.service';
import { TranslateService } from '@ngx-translate/core';
......@@ -26,7 +26,7 @@ import { Router } from '@angular/router';
templateUrl: './comment-list.component.html',
styleUrls: ['./comment-list.component.scss']
})
export class CommentListComponent implements OnInit {
export class CommentListComponent implements OnInit, OnDestroy {
@ViewChild('searchBox') searchField: ElementRef;
@Input() user: User;
@Input() roomId: string;
......@@ -114,6 +114,12 @@ export class CommentListComponent implements OnInit {
});
}
ngOnDestroy() {
if (!this.freeze && this.commentStream) {
this.commentStream.unsubscribe();
}
}
checkScroll(): void {
const currentScroll = document.documentElement.scrollTop;
this.scroll = currentScroll >= 65;
......
import { Component, OnInit } from '@angular/core';
import { Component, OnInit, OnDestroy } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { AuthenticationService } from '../../../services/http/authentication.service';
import { UserRole } from '../../../models/user-roles.enum';
import { NotificationService } from '../../../services/util/notification.service';
import { Message } from '@stomp/stompjs';
import { WsFeedbackService } from '../../../services/websockets/ws-feedback.service';
import { Subscription } from 'rxjs';
/* ToDo: Use TranslateService */
......@@ -13,7 +14,7 @@ import { WsFeedbackService } from '../../../services/websockets/ws-feedback.serv
templateUrl: './feedback-barometer-page.component.html',
styleUrls: ['./feedback-barometer-page.component.scss']
})
export class FeedbackBarometerPageComponent implements OnInit {
export class FeedbackBarometerPageComponent implements OnInit, OnDestroy {
feedback: any = [
{ state: 0, name: 'sentiment_very_satisfied', message: 'Ich kann folgen.', count: 0, },
{ state: 1, name: 'sentiment_satisfied', message: 'Schneller, bitte!', count: 0, },
......@@ -22,6 +23,7 @@ export class FeedbackBarometerPageComponent implements OnInit {
];
userRole: UserRole;
roomId: string;
protected sub: Subscription;
constructor(
private authenticationService: AuthenticationService,
......@@ -34,13 +36,19 @@ export class FeedbackBarometerPageComponent implements OnInit {
ngOnInit() {
this.userRole = this.authenticationService.getRole();
this.wsFeedbackService.getFeedbackStream(this.roomId).subscribe((message: Message) => {
this.sub = this.wsFeedbackService.getFeedbackStream(this.roomId).subscribe((message: Message) => {
this.parseIncomingMessage(message);
});
this.wsFeedbackService.get(this.roomId);
}
ngOnDestroy() {
if (this.sub) {
this.sub.unsubscribe();
}
}
private updateFeedback(data) {
const reducer = (accumulator, currentValue) => accumulator + currentValue;
const sum = data.reduce(reducer);
......
import { Component, Input, OnInit } from '@angular/core';
import { Component, Input, OnInit, OnDestroy } from '@angular/core';
import { Room } from '../../../models/room';
import { RoomRoleMixin } from '../../../models/room-role-mixin';
import { User } from '../../../models/user';
......@@ -9,18 +9,20 @@ import { EventService } from '../../../services/util/event.service';
import { AuthenticationService } from '../../../services/http/authentication.service';
import { ModeratorService } from '../../../services/http/moderator.service';
import { MatTableDataSource } from '@angular/material';
import { Subscription } from 'rxjs';
@Component({
selector: 'app-room-list',
templateUrl: './room-list.component.html',
styleUrls: ['./room-list.component.scss']
})
export class RoomListComponent implements OnInit {
export class RoomListComponent implements OnInit, OnDestroy {
@Input() user: User;
rooms: Room[] = [];
roomsWithRole: RoomRoleMixin[];
closedRooms: Room[];
isLoading = true;
sub: Subscription;
tableDataSource: MatTableDataSource<Room>;
displayedColumns: string[] = ['name', 'shortId', 'role', 'button'];
......@@ -39,11 +41,17 @@ export class RoomListComponent implements OnInit {
ngOnInit() {
this.getRooms();
this.eventService.on<any>('RoomDeleted').subscribe(payload => {
this.sub = this.eventService.on<any>('RoomDeleted').subscribe(payload => {
this.roomsWithRole = this.roomsWithRole.filter(r => r.id !== payload.id);
});
}
ngOnDestroy() {
if (this.sub) {
this.sub.unsubscribe();
}
}
getRooms(): void {
this.roomService.getParticipantRooms().subscribe(rooms => this.updateRoomList(rooms));
this.roomService.getCreatorRooms().subscribe(rooms => this.updateRoomList(rooms));
......
import { Component, OnInit } from '@angular/core';
import { Component, OnInit, OnDestroy } from '@angular/core';
import { Room } from '../../../models/room';
import { RoomService } from '../../../services/http/room.service';
import { ActivatedRoute } from '@angular/router';
import { Location } from '@angular/common';
import { WsCommentServiceService } from '../../../services/websockets/ws-comment-service.service';
import { CommentService } from '../../../services/http/comment.service';
import { Message } from '@stomp/stompjs';
import { EventService } from '../../../services/util/event.service';
import { Message, IMessage } from '@stomp/stompjs';
import { Observable, Subscription } from 'rxjs';
@Component({
selector: 'app-room-page',
templateUrl: './room-page.component.html',
styleUrls: ['./room-page.component.scss']
})
export class RoomPageComponent implements OnInit {
export class RoomPageComponent implements OnInit, OnDestroy {
room: Room = null;
isLoading = true;
commentCounter: number;
protected moderationEnabled = false;
protected sub: Subscription;
protected commentWatch: Observable<IMessage>;
protected listenerFn: () => void;
constructor(protected roomService: RoomService,
protected route: ActivatedRoute,
protected location: Location,
protected wsCommentService: WsCommentServiceService,
protected commentService: CommentService
protected commentService: CommentService,
protected eventService: EventService
) {
}
......@@ -32,6 +38,14 @@ export class RoomPageComponent implements OnInit {
});
}
ngOnDestroy() {
this.listenerFn();
this.eventService.makeFocusOnInputFalse();
if (this.sub) {
this.sub.unsubscribe();
}
}
protected afterRoomLoadHook() {
}
......@@ -51,7 +65,8 @@ export class RoomPageComponent implements OnInit {
.subscribe(commentCounter => {
this.commentCounter = commentCounter;
});
this.wsCommentService.getCommentStream(this.room.id).subscribe((message: Message) => {
this.commentWatch = this.wsCommentService.getCommentStream(this.room.id);
this.sub = this.commentWatch.subscribe((message: Message) => {
const msg = JSON.parse(message.body);
const payload = msg.payload;
if (msg.type === 'CommentCreated') {
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment