diff --git a/src/app/components/stream/status/action-bar/action-bar.component.ts b/src/app/components/stream/status/action-bar/action-bar.component.ts index 96db14bd..db21919f 100644 --- a/src/app/components/stream/status/action-bar/action-bar.component.ts +++ b/src/app/components/stream/status/action-bar/action-bar.component.ts @@ -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) => { diff --git a/src/app/services/mastodon.service.ts b/src/app/services/mastodon.service.ts index b106831f..68048f6b 100644 --- a/src/app/services/mastodon.service.ts +++ b/src/app/services/mastodon.service.ts @@ -173,13 +173,13 @@ export class MastodonService { return this.httpClient.post(route, null, { headers: headers }).toPromise() } - favorite(account: AccountInfo, status: Status): any { + favorite(account: AccountInfo, status: Status): Promise { 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(route, null, { headers: headers }).toPromise() } - unfavorite(account: AccountInfo, status: Status): any { + unfavorite(account: AccountInfo, status: Status): Promise { 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(route, null, { headers: headers }).toPromise()