fix boosting/faving when not up to date
This commit is contained in:
parent
5547b19727
commit
72fc5bd387
|
@ -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) => {
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue