status notification added in thread

This commit is contained in:
Nicolas Constant 2020-04-18 19:09:01 -04:00
parent 9c53010ae8
commit 82206bc9c9
No known key found for this signature in database
GPG Key ID: 1E9F677FB01A5688
1 changed files with 18 additions and 0 deletions

View File

@ -10,6 +10,7 @@ import { AccountInfo } from '../../../states/accounts.state';
import { StatusWrapper } from '../../../models/common.model';
import { StatusComponent } from '../status/status.component';
import scrollIntoView from 'scroll-into-view-if-needed';
import { UserNotificationService, UserNotification } from '../../../services/user-notification.service';
@Component({
selector: 'app-thread',
@ -50,10 +51,12 @@ export class ThreadComponent implements OnInit, OnDestroy {
private deleteStatusSubscription: Subscription;
private refreshSubscription: Subscription;
private goToTopSubscription: Subscription;
private responseSubscription: Subscription;
constructor(
private readonly httpClient: HttpClient,
private readonly notificationService: NotificationService,
private readonly userNotificationService: UserNotificationService,
private readonly toolsService: ToolsService,
private readonly mastodonService: MastodonWrapperService) { }
@ -102,6 +105,20 @@ export class ThreadComponent implements OnInit, OnDestroy {
});
}
});
this.responseSubscription = this.userNotificationService.userNotifications.subscribe((userNotifications: UserNotification[]) => {
userNotifications.forEach(x => {
x.mentions.forEach(y => {
if(y.status){
if(this.statuses.map(z => z.status.id).includes(y.status.in_reply_to_id) && !this.statuses.map(z => z.status.uri).includes(y.status.uri)) {
let cwResult = this.toolsService.checkContentWarning(y.status);
this.statuses.push(new StatusWrapper(y.status, x.account, cwResult.applyCw, cwResult.hide));
return;
}
}
});
});
});
}
ngOnDestroy(): void {
@ -110,6 +127,7 @@ export class ThreadComponent implements OnInit, OnDestroy {
if (this.deleteStatusSubscription) this.deleteStatusSubscription.unsubscribe();
if (this.refreshSubscription) this.refreshSubscription.unsubscribe();
if (this.goToTopSubscription) this.goToTopSubscription.unsubscribe();
if (this.responseSubscription) this.responseSubscription.unsubscribe();
}
@ViewChild('statusstream') public statustream: ElementRef;