removing muted/blocked from timelines

This commit is contained in:
Nicolas Constant 2019-07-03 18:55:46 -04:00
parent dac2cbfabd
commit 84fe025f47
No known key found for this signature in database
GPG Key ID: 1E9F677FB01A5688
3 changed files with 37 additions and 2 deletions

View File

@ -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);

View File

@ -59,6 +59,7 @@ export class StreamStatusesComponent implements OnInit, OnDestroy {
private goToTopSubscription: Subscription;
private streamsSubscription: Subscription;
private hideAccountSubscription: Subscription;
private streams$: Observable<StreamElement[]>;
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 {

View File

@ -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<NotificatioData>();
public newRespondPostedStream = new Subject<NewReplyData>();
public hideAccountUrlStream = new Subject<string>();
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 {