fix boosting/faving when not up to date

This commit is contained in:
Nicolas Constant 2019-03-31 19:08:11 -04:00
parent 5547b19727
commit 72fc5bd387
No known key found for this signature in database
GPG Key ID: 1E9F677FB01A5688
2 changed files with 10 additions and 6 deletions

View File

@ -119,10 +119,12 @@ export class ActionBarComponent implements OnInit, OnDestroy {
const usableStatus = this.toolsService.getStatusUsableByAccount(account, this.statusWrapper);
usableStatus
.then((status: Status) => {
if (this.isBoosted) {
if (this.isBoosted && status.reblogged) {
return this.mastodonService.unreblog(account, status);
} else {
} else if(!this.isBoosted && !status.reblogged){
return this.mastodonService.reblog(account, status);
} else {
return Promise.resolve(status);
}
})
.then((boostedStatus: Status) => {
@ -144,10 +146,12 @@ export class ActionBarComponent implements OnInit, OnDestroy {
const usableStatus = this.toolsService.getStatusUsableByAccount(account, this.statusWrapper);
usableStatus
.then((status: Status) => {
if (this.isFavorited) {
if (this.isFavorited && status.favourited) {
return this.mastodonService.unfavorite(account, status);
} else {
} else if(!this.isFavorited && !status.favourited) {
return this.mastodonService.favorite(account, status);
} else {
return Promise.resolve(status);
}
})
.then((favoritedStatus: Status) => {

View File

@ -173,13 +173,13 @@ export class MastodonService {
return this.httpClient.post<Status>(route, null, { headers: headers }).toPromise()
}
favorite(account: AccountInfo, status: Status): any {
favorite(account: AccountInfo, status: Status): Promise<Status> {
const route = `https://${account.instance}${this.apiRoutes.favouritingStatus}`.replace('{0}', status.id);
const headers = new HttpHeaders({ 'Authorization': `Bearer ${account.token.access_token}` });
return this.httpClient.post<Status>(route, null, { headers: headers }).toPromise()
}
unfavorite(account: AccountInfo, status: Status): any {
unfavorite(account: AccountInfo, status: Status): Promise<Status> {
const route = `https://${account.instance}${this.apiRoutes.unfavouritingStatus}`.replace('{0}', status.id);
const headers = new HttpHeaders({ 'Authorization': `Bearer ${account.token.access_token}` });
return this.httpClient.post<Status>(route, null, { headers: headers }).toPromise()