Merge pull request #258 from NicolasConstant/topic_add-response-thread

status notification added in thread
This commit is contained in:
Nicolas Constant 2020-04-18 19:52:08 -04:00 committed by GitHub
commit 19bb19c5b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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;