Merge pull request #364 from NicolasConstant/topic_fix-fav-issues
Topic fix fav issues
This commit is contained in:
commit
14a9aade0b
|
@ -102,13 +102,13 @@ export class ActionBarComponent implements OnInit, OnDestroy {
|
||||||
this.statusStateSub = this.statusStateService.stateNotification.subscribe((state: StatusState) => {
|
this.statusStateSub = this.statusStateService.stateNotification.subscribe((state: StatusState) => {
|
||||||
if (state && state.statusId === this.displayedStatus.url) {
|
if (state && state.statusId === this.displayedStatus.url) {
|
||||||
|
|
||||||
if (state.isFavorited) {
|
if (state.isFavorited !== null) {
|
||||||
this.favoriteStatePerAccountId[state.accountId] = state.isFavorited;
|
this.favoriteStatePerAccountId[state.accountId] = state.isFavorited;
|
||||||
}
|
}
|
||||||
if (state.isRebloged) {
|
if (state.isRebloged !== null) {
|
||||||
this.bootedStatePerAccountId[state.accountId] = state.isRebloged;
|
this.bootedStatePerAccountId[state.accountId] = state.isRebloged;
|
||||||
}
|
}
|
||||||
if (state.isBookmarked) {
|
if (state.isBookmarked !== null) {
|
||||||
this.bookmarkStatePerAccountId[state.accountId] = state.isBookmarked;
|
this.bookmarkStatePerAccountId[state.accountId] = state.isBookmarked;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -184,13 +184,18 @@ export class ActionBarComponent implements OnInit, OnDestroy {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boostPromise: Promise<any>;
|
||||||
boost(): boolean {
|
boost(): boolean {
|
||||||
if (this.boostIsLoading) return;
|
if (!this.boostPromise) {
|
||||||
|
this.boostPromise = Promise.resolve(true);
|
||||||
|
}
|
||||||
|
|
||||||
this.boostIsLoading = true;
|
|
||||||
const account = this.toolsService.getSelectedAccounts()[0];
|
const account = this.toolsService.getSelectedAccounts()[0];
|
||||||
const usableStatus = this.toolsService.getStatusUsableByAccount(account, this.statusWrapper);
|
this.boostPromise = this.boostPromise
|
||||||
usableStatus
|
.then(() => {
|
||||||
|
this.boostIsLoading = true;
|
||||||
|
return this.toolsService.getStatusUsableByAccount(account, this.statusWrapper);
|
||||||
|
})
|
||||||
.then((status: Status) => {
|
.then((status: Status) => {
|
||||||
if (this.isBoosted && status.reblogged) {
|
if (this.isBoosted && status.reblogged) {
|
||||||
return this.mastodonService.unreblog(account, status);
|
return this.mastodonService.unreblog(account, status);
|
||||||
|
@ -219,18 +224,24 @@ export class ActionBarComponent implements OnInit, OnDestroy {
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.statusStateService.statusReblogStatusChanged(this.displayedStatus.url, account.id, this.bootedStatePerAccountId[account.id]);
|
this.statusStateService.statusReblogStatusChanged(this.displayedStatus.url, account.id, this.bootedStatePerAccountId[account.id]);
|
||||||
this.boostIsLoading = false;
|
this.boostIsLoading = false;
|
||||||
|
this.boostPromise = null;
|
||||||
});
|
});
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private favoritePromise: Promise<any>;
|
||||||
favorite(): boolean {
|
favorite(): boolean {
|
||||||
if (this.favoriteIsLoading) return;
|
if (!this.favoritePromise) {
|
||||||
|
this.favoritePromise = Promise.resolve(true);
|
||||||
|
}
|
||||||
|
|
||||||
this.favoriteIsLoading = true;
|
|
||||||
const account = this.toolsService.getSelectedAccounts()[0];
|
const account = this.toolsService.getSelectedAccounts()[0];
|
||||||
const usableStatus = this.toolsService.getStatusUsableByAccount(account, this.statusWrapper);
|
this.favoritePromise = this.favoritePromise
|
||||||
usableStatus
|
.then(() => {
|
||||||
|
this.favoriteIsLoading = true;
|
||||||
|
return this.toolsService.getStatusUsableByAccount(account, this.statusWrapper);
|
||||||
|
})
|
||||||
.then((status: Status) => {
|
.then((status: Status) => {
|
||||||
if (this.isFavorited && status.favourited) {
|
if (this.isFavorited && status.favourited) {
|
||||||
return this.mastodonService.unfavorite(account, status);
|
return this.mastodonService.unfavorite(account, status);
|
||||||
|
@ -254,19 +265,24 @@ export class ActionBarComponent implements OnInit, OnDestroy {
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.statusStateService.statusFavoriteStatusChanged(this.displayedStatus.url, account.id, this.favoriteStatePerAccountId[account.id]);
|
this.statusStateService.statusFavoriteStatusChanged(this.displayedStatus.url, account.id, this.favoriteStatePerAccountId[account.id]);
|
||||||
this.favoriteIsLoading = false;
|
this.favoriteIsLoading = false;
|
||||||
|
this.favoritePromise = null;
|
||||||
});
|
});
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bookmarkPromise: Promise<any>;
|
||||||
bookmark(): boolean {
|
bookmark(): boolean {
|
||||||
if (this.bookmarkingIsLoading) return;
|
if (!this.bookmarkPromise) {
|
||||||
|
this.bookmarkPromise = Promise.resolve(true);
|
||||||
this.bookmarkingIsLoading = true;
|
}
|
||||||
|
|
||||||
const account = this.toolsService.getSelectedAccounts()[0];
|
const account = this.toolsService.getSelectedAccounts()[0];
|
||||||
const usableStatus = this.toolsService.getStatusUsableByAccount(account, this.statusWrapper);
|
this.bookmarkPromise = this.bookmarkPromise
|
||||||
usableStatus
|
.then(() => {
|
||||||
|
this.bookmarkingIsLoading = true;
|
||||||
|
return this.toolsService.getStatusUsableByAccount(account, this.statusWrapper);
|
||||||
|
})
|
||||||
.then((status: Status) => {
|
.then((status: Status) => {
|
||||||
if (this.isBookmarked && status.bookmarked) {
|
if (this.isBookmarked && status.bookmarked) {
|
||||||
return this.mastodonService.unbookmark(account, status);
|
return this.mastodonService.unbookmark(account, status);
|
||||||
|
@ -290,15 +306,9 @@ export class ActionBarComponent implements OnInit, OnDestroy {
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.statusStateService.statusBookmarkStatusChanged(this.displayedStatus.url, account.id, this.bookmarkStatePerAccountId[account.id]);
|
this.statusStateService.statusBookmarkStatusChanged(this.displayedStatus.url, account.id, this.bookmarkStatePerAccountId[account.id]);
|
||||||
this.bookmarkingIsLoading = false;
|
this.bookmarkingIsLoading = false;
|
||||||
|
this.bookmarkPromise = null;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// setTimeout(() => {
|
|
||||||
// this.isBookmarked = !this.isBookmarked;
|
|
||||||
// this.bookmarkingIsLoading = false;
|
|
||||||
// }, 2000);
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue