...
 
Commits (2)
......@@ -4,6 +4,7 @@ import { ActivatedRoute } from '@angular/router';
import { Client } from '../../../../services/api';
import { UpdateMarkersService } from '../../../../common/services/update-markers.service';
import { VideoChatService } from '../../../videochat/videochat.service';
import {timer, Subscription} from 'rxjs';
@Component({
selector: 'm-group--member-previews',
......@@ -17,9 +18,10 @@ export class GroupMemberPreviews {
count: Number = 0;
inProgress: boolean = false;
minds = window.Minds;
gatheringParticipantTimer;
private updateMarkersSubscription;
private gatheringParticipantsInterval;
private updateMarkersSubscription: Subscription;
private gatheringParticipantUpdateSubscription: Subscription;
constructor(
private client: Client,
......@@ -27,6 +29,8 @@ export class GroupMemberPreviews {
) { }
ngOnInit() {
const checkIntervalSeconds = 2;
this.gatheringParticipantTimer = timer(0, checkIntervalSeconds * 1000);
this.load();
}
......@@ -34,7 +38,10 @@ export class GroupMemberPreviews {
if (this.updateMarkersSubscription) {
this.updateMarkersSubscription.unsubscribe();
}
clearInterval(this.gatheringParticipantsInterval);
if (this.gatheringParticipantUpdateSubscription) {
this.gatheringParticipantUpdateSubscription.unsubscribe();
}
}
async load() {
......@@ -69,34 +76,23 @@ export class GroupMemberPreviews {
}
}).bind(this));
this.pollGatheringParticipants();
this.gatheringParticipantUpdateSubscription = this.gatheringParticipantTimer.subscribe(() => this.updateGatheringParticipants());
}
userIsInGathering(user_guid) {
for (let member of this.members) {
if (member.guid === user_guid) {
console.log('user entered gathering: ' + member.guid); // TODO: Remove debug log
member.inGathering = true;
member.lastGatheringMarkerTimestamp = this.currentTimestamp();
}
}
}
pollGatheringParticipants() {
const checkIntervalSeconds = 2;
clearInterval(this.gatheringParticipantsInterval);
this.gatheringParticipantsInterval = setInterval(() => {
this.checkGatheringParticipantsForMarkerTimeout();
}, checkIntervalSeconds);
}
checkGatheringParticipantsForMarkerTimeout() {
updateGatheringParticipants() {
const timestampThreshold = this.currentTimestamp() - (2 * VideoChatService.heartBeatIntervalSeconds);
for (let member of this.members) {
if (member.inGathering) {
if (member.lastGatheringMarkerTimestamp < timestampThreshold) {
console.log('user left gathering: ' + member.guid); // TODO: Remove debug log
member.inGathering = false;
}
}
......