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) this.toolsService.findAccount(acc, this.fullHandle)
.then((target: Account) => { .then((target: Account) => {
this.mastodonService.mute(acc, target.id); this.mastodonService.mute(acc, target.id);
return target;
})
.then((target: Account) => {
this.notificationService.hideAccount(target);
}) })
.catch(err => { .catch(err => {
this.notificationService.notifyHttpError(err); this.notificationService.notifyHttpError(err);
@ -302,6 +306,10 @@ export class ActionBarComponent implements OnInit, OnDestroy {
this.toolsService.findAccount(acc, this.fullHandle) this.toolsService.findAccount(acc, this.fullHandle)
.then((target: Account) => { .then((target: Account) => {
this.mastodonService.block(acc, target.id); this.mastodonService.block(acc, target.id);
return target;
})
.then((target: Account) => {
this.notificationService.hideAccount(target);
}) })
.catch(err => { .catch(err => {
this.notificationService.notifyHttpError(err); this.notificationService.notifyHttpError(err);

View File

@ -59,6 +59,7 @@ export class StreamStatusesComponent implements OnInit, OnDestroy {
private goToTopSubscription: Subscription; private goToTopSubscription: Subscription;
private streamsSubscription: Subscription; private streamsSubscription: Subscription;
private hideAccountSubscription: Subscription;
private streams$: Observable<StreamElement[]>; private streams$: Observable<StreamElement[]>;
constructor( constructor(
@ -85,11 +86,32 @@ export class StreamStatusesComponent implements OnInit, OnDestroy {
this.streamElement = updatedStream; 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() { ngOnDestroy() {
if (this.goToTopSubscription) this.goToTopSubscription.unsubscribe(); if (this.goToTopSubscription) this.goToTopSubscription.unsubscribe();
if (this.streamsSubscription) this.streamsSubscription.unsubscribe(); if (this.streamsSubscription) this.streamsSubscription.unsubscribe();
if (this.hideAccountSubscription) this.hideAccountSubscription.unsubscribe();
} }
refresh(): any { refresh(): any {

View File

@ -2,12 +2,13 @@ import { Injectable } from '@angular/core';
import { Subject } from 'rxjs'; import { Subject } from 'rxjs';
import { HttpErrorResponse } from '@angular/common/http'; import { HttpErrorResponse } from '@angular/common/http';
import { StatusWrapper } from '../models/common.model'; import { StatusWrapper } from '../models/common.model';
import { Status } from './models/mastodon.interfaces'; import { Account } from './models/mastodon.interfaces';
@Injectable() @Injectable()
export class NotificationService { export class NotificationService {
public notifactionStream = new Subject<NotificatioData>(); public notifactionStream = new Subject<NotificatioData>();
public newRespondPostedStream = new Subject<NewReplyData>(); public newRespondPostedStream = new Subject<NewReplyData>();
public hideAccountUrlStream = new Subject<string>();
constructor() { constructor() {
} }
@ -31,6 +32,10 @@ export class NotificationService {
const notification = new NewReplyData(uiStatusRepliedToId, response); const notification = new NewReplyData(uiStatusRepliedToId, response);
this.newRespondPostedStream.next(notification); this.newRespondPostedStream.next(notification);
} }
public hideAccount(account: Account){
this.hideAccountUrlStream.next(account.url);
}
} }
export class NotificatioData { export class NotificatioData {