added mute block capability

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

View File

@ -71,6 +71,7 @@ export class ActionBarComponent implements OnInit, OnDestroy {
username: string;
private fullHandle: string;
private displayedStatus: Status;
private loadedAccounts: AccountInfo[];
ngOnInit() {
const status = this.statusWrapper.status;
@ -89,6 +90,7 @@ export class ActionBarComponent implements OnInit, OnDestroy {
}
this.accountSub = this.accounts$.subscribe((accounts: AccountInfo[]) => {
this.loadedAccounts = accounts;
this.checkStatus(accounts);
});
}
@ -272,6 +274,7 @@ export class ActionBarComponent implements OnInit, OnDestroy {
mentionAccount(): boolean {
return false;
}
@ -281,13 +284,30 @@ export class ActionBarComponent implements OnInit, OnDestroy {
}
muteAccount(): boolean {
this.loadedAccounts.forEach(acc => {
this.toolsService.findAccount(acc, this.fullHandle)
.then((target: Account) => {
this.mastodonService.mute(acc, target.id);
})
.catch(err => {
this.notificationService.notifyHttpError(err);
});
});
return false;
}
blockAccount(): boolean {
this.loadedAccounts.forEach(acc => {
this.toolsService.findAccount(acc, this.fullHandle)
.then((target: Account) => {
this.mastodonService.block(acc, target.id);
})
.catch(err => {
this.notificationService.notifyHttpError(err);
});
});
return false;
}
}

View File

@ -320,6 +320,18 @@ export class MastodonService {
const headers = new HttpHeaders({ 'Authorization': `Bearer ${account.token.access_token}` });
return this.httpClient.get<Poll>(route, { headers: headers }).toPromise();
}
mute(account: AccountInfo, accounId: number): Promise<Relationship> {
let route = `https://${account.instance}${this.apiRoutes.mute}`.replace('{0}', accounId.toString());
const headers = new HttpHeaders({ 'Authorization': `Bearer ${account.token.access_token}` });
return this.httpClient.post<Relationship>(route, null, { headers: headers }).toPromise();
}
block(account: AccountInfo, accounId: number): Promise<Relationship> {
let route = `https://${account.instance}${this.apiRoutes.block}`.replace('{0}', accounId.toString());
const headers = new HttpHeaders({ 'Authorization': `Bearer ${account.token.access_token}` });
return this.httpClient.post<Relationship>(route, null, { headers: headers }).toPromise();
}
}
export enum VisibilityEnum {