added mute block capability
This commit is contained in:
parent
a35c7e911d
commit
dac2cbfabd
|
@ -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);
|
||||
});
|
||||
}
|
||||
|
@ -271,6 +273,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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ import { AccountInfo } from '../states/accounts.state';
|
|||
import { StreamTypeEnum, StreamElement } from '../states/streams.state';
|
||||
|
||||
@Injectable()
|
||||
export class MastodonService {
|
||||
export class MastodonService {
|
||||
private apiRoutes = new ApiRoutes();
|
||||
|
||||
constructor(private readonly httpClient: HttpClient) { }
|
||||
|
@ -319,6 +319,18 @@ export class MastodonService {
|
|||
let route = `https://${account.instance}${this.apiRoutes.getPoll}`.replace('{0}', pollId);
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue