From 84fe025f47293bc85fe46ba3f58138641227520d Mon Sep 17 00:00:00 2001 From: Nicolas Constant Date: Wed, 3 Jul 2019 18:55:46 -0400 Subject: [PATCH] removing muted/blocked from timelines --- .../status/action-bar/action-bar.component.ts | 8 +++++++ .../stream-statuses.component.ts | 24 ++++++++++++++++++- src/app/services/notification.service.ts | 7 +++++- 3 files changed, 37 insertions(+), 2 deletions(-) diff --git a/src/app/components/stream/status/action-bar/action-bar.component.ts b/src/app/components/stream/status/action-bar/action-bar.component.ts index 44d711d5..3cb6f9bf 100644 --- a/src/app/components/stream/status/action-bar/action-bar.component.ts +++ b/src/app/components/stream/status/action-bar/action-bar.component.ts @@ -288,6 +288,10 @@ export class ActionBarComponent implements OnInit, OnDestroy { this.toolsService.findAccount(acc, this.fullHandle) .then((target: Account) => { this.mastodonService.mute(acc, target.id); + return target; + }) + .then((target: Account) => { + this.notificationService.hideAccount(target); }) .catch(err => { this.notificationService.notifyHttpError(err); @@ -302,6 +306,10 @@ export class ActionBarComponent implements OnInit, OnDestroy { this.toolsService.findAccount(acc, this.fullHandle) .then((target: Account) => { this.mastodonService.block(acc, target.id); + return target; + }) + .then((target: Account) => { + this.notificationService.hideAccount(target); }) .catch(err => { this.notificationService.notifyHttpError(err); diff --git a/src/app/components/stream/stream-statuses/stream-statuses.component.ts b/src/app/components/stream/stream-statuses/stream-statuses.component.ts index bf839349..14be2596 100644 --- a/src/app/components/stream/stream-statuses/stream-statuses.component.ts +++ b/src/app/components/stream/stream-statuses/stream-statuses.component.ts @@ -59,6 +59,7 @@ export class StreamStatusesComponent implements OnInit, OnDestroy { private goToTopSubscription: Subscription; private streamsSubscription: Subscription; + private hideAccountSubscription: Subscription; private streams$: Observable; constructor( @@ -78,18 +79,39 @@ export class StreamStatusesComponent implements OnInit, OnDestroy { this.streamsSubscription = this.streams$.subscribe((streams: StreamElement[]) => { let updatedStream = streams.find(x => x.id === this.streamElement.id); - + if (this.hideBoosts !== updatedStream.hideBoosts || this.hideBots !== updatedStream.hideBots || this.hideReplies !== updatedStream.hideReplies) { this.streamElement = updatedStream; } }); + + this.hideAccountSubscription = this.notificationService.hideAccountUrlStream.subscribe((accountUrl: string) => { + if (accountUrl) { + this.statuses = this.statuses.filter(x => { + if(x.status.reblog){ + return x.status.reblog.account.url != accountUrl; + } else { + return x.status.account.url != accountUrl; + } + }); + + this.bufferStream = this.bufferStream.filter(x => { + if(x.reblog){ + return x.reblog.account.url != accountUrl; + } else { + return x.account.url != accountUrl; + } + }); + } + }); } ngOnDestroy() { if (this.goToTopSubscription) this.goToTopSubscription.unsubscribe(); if (this.streamsSubscription) this.streamsSubscription.unsubscribe(); + if (this.hideAccountSubscription) this.hideAccountSubscription.unsubscribe(); } refresh(): any { diff --git a/src/app/services/notification.service.ts b/src/app/services/notification.service.ts index d44ad91a..c9520e8a 100644 --- a/src/app/services/notification.service.ts +++ b/src/app/services/notification.service.ts @@ -2,12 +2,13 @@ import { Injectable } from '@angular/core'; import { Subject } from 'rxjs'; import { HttpErrorResponse } from '@angular/common/http'; import { StatusWrapper } from '../models/common.model'; -import { Status } from './models/mastodon.interfaces'; +import { Account } from './models/mastodon.interfaces'; @Injectable() export class NotificationService { public notifactionStream = new Subject(); public newRespondPostedStream = new Subject(); + public hideAccountUrlStream = new Subject(); constructor() { } @@ -31,6 +32,10 @@ export class NotificationService { const notification = new NewReplyData(uiStatusRepliedToId, response); this.newRespondPostedStream.next(notification); } + + public hideAccount(account: Account){ + this.hideAccountUrlStream.next(account.url); + } } export class NotificatioData {