fix #74
This commit is contained in:
parent
caad3689f1
commit
8559d170f9
|
@ -4,7 +4,9 @@
|
|||
</a>
|
||||
<ion-icon *ngIf="isLocked" class="action-bar__lock" name="lock" title="Account can't access this post"></ion-icon>
|
||||
|
||||
<a *ngIf="!(isBoostLocked || isLocked)" href class="action-bar__link" title="Boost" [class.boosted]="isBoosted"
|
||||
<a *ngIf="!(isBoostLocked || isLocked)" href class="action-bar__link" title="Boost"
|
||||
[class.boosted]="isBoosted"
|
||||
[class.boosting]="boostIsLoading"
|
||||
(click)="boost()">
|
||||
<ion-icon name="md-swap"></ion-icon>
|
||||
</a>
|
||||
|
@ -12,7 +14,9 @@
|
|||
title="This post cannot be boosted"></ion-icon>
|
||||
<ion-icon *ngIf="isLocked" class="action-bar__lock" name="lock" title="Account can't access this post"></ion-icon>
|
||||
|
||||
<a *ngIf="!isLocked" href class="action-bar__link" title="Favourite" [class.favorited]="isFavorited"
|
||||
<a *ngIf="!isLocked" href class="action-bar__link" title="Favourite"
|
||||
[class.favorited]="isFavorited"
|
||||
[class.favoriting]="favoriteIsLoading"
|
||||
(click)="favorite()">
|
||||
<ion-icon name="md-star"></ion-icon>
|
||||
</a>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
@import "variables";
|
||||
|
||||
.action-bar {
|
||||
// outline: 1px solid greenyellow; // height: 20px;
|
||||
margin: 5px 10px 5px $avatar-column-space;
|
||||
|
@ -9,9 +10,11 @@
|
|||
|
||||
&__link {
|
||||
color: $status-secondary-color;
|
||||
|
||||
&:hover {
|
||||
color: $status-links-color;
|
||||
}
|
||||
|
||||
&:not(:last-child) {
|
||||
margin-right: 15px;
|
||||
}
|
||||
|
@ -50,9 +53,9 @@
|
|||
|
||||
.boosted {
|
||||
color: $boost-color;
|
||||
|
||||
|
||||
&:hover {
|
||||
color: darken($boost-color, 10);
|
||||
color: darken($boost-color, 10);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -62,4 +65,70 @@
|
|||
&:hover {
|
||||
color: darken($favorite-color, 10);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@keyframes loadingAnimation {
|
||||
0% {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
50% {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
100% {
|
||||
opacity: 0;
|
||||
}
|
||||
}
|
||||
|
||||
@-o-keyframes loadingAnimation {
|
||||
0% {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
50% {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
100% {
|
||||
opacity: 0;
|
||||
}
|
||||
}
|
||||
|
||||
@-moz-keyframes loadingAnimation {
|
||||
0% {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
50% {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
100% {
|
||||
opacity: 0;
|
||||
}
|
||||
}
|
||||
|
||||
@-webkit-keyframes loadingAnimation {
|
||||
0% {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
50% {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
100% {
|
||||
opacity: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.boosting,
|
||||
.favoriting {
|
||||
-webkit-animation: loadingAnimation 1s infinite;
|
||||
-moz-animation: loadingAnimation 1s infinite;
|
||||
-o-animation: loadingAnimation 1s infinite;
|
||||
animation: loadingAnimation 1s infinite;
|
||||
|
||||
}
|
|
@ -34,6 +34,9 @@ export class ActionBarComponent implements OnInit, OnDestroy {
|
|||
isBoostLocked: boolean;
|
||||
isLocked: boolean;
|
||||
|
||||
favoriteIsLoading: boolean;
|
||||
boostIsLoading: boolean;
|
||||
|
||||
isContentWarningActive: boolean = false;
|
||||
|
||||
private isProviderSelected: boolean;
|
||||
|
@ -48,7 +51,7 @@ export class ActionBarComponent implements OnInit, OnDestroy {
|
|||
constructor(
|
||||
private readonly store: Store,
|
||||
private readonly toolsService: ToolsService,
|
||||
private readonly mastodonService: MastodonService,
|
||||
private readonly mastodonService: MastodonService,
|
||||
private readonly notificationService: NotificationService) {
|
||||
|
||||
this.accounts$ = this.store.select(state => state.registeredaccounts.accounts);
|
||||
|
@ -87,7 +90,7 @@ export class ActionBarComponent implements OnInit, OnDestroy {
|
|||
this.isLocked = false;
|
||||
}
|
||||
|
||||
if(status.sensitive || status.spoiler_text){
|
||||
if (status.sensitive || status.spoiler_text) {
|
||||
this.isContentWarningActive = true;
|
||||
}
|
||||
|
||||
|
@ -113,56 +116,63 @@ export class ActionBarComponent implements OnInit, OnDestroy {
|
|||
}
|
||||
|
||||
boost(): boolean {
|
||||
//TODO get rid of that
|
||||
this.selectedAccounts.forEach((account: AccountInfo) => {
|
||||
if(this.boostIsLoading) return;
|
||||
|
||||
const usableStatus = this.toolsService.getStatusUsableByAccount(account, this.statusWrapper);
|
||||
usableStatus
|
||||
.then((status: Status) => {
|
||||
if (this.isBoosted && status.reblogged) {
|
||||
return this.mastodonService.unreblog(account, status);
|
||||
} else if(!this.isBoosted && !status.reblogged){
|
||||
return this.mastodonService.reblog(account, status);
|
||||
} else {
|
||||
return Promise.resolve(status);
|
||||
}
|
||||
})
|
||||
.then((boostedStatus: Status) => {
|
||||
this.bootedStatePerAccountId[account.id] = boostedStatus.reblogged;
|
||||
this.checkIfBoosted();
|
||||
// this.isBoosted = !this.isBoosted;
|
||||
})
|
||||
.catch((err: HttpErrorResponse) => {
|
||||
this.notificationService.notifyHttpError(err);
|
||||
});
|
||||
});
|
||||
this.boostIsLoading = true;
|
||||
const account = this.toolsService.getSelectedAccounts()[0];
|
||||
const usableStatus = this.toolsService.getStatusUsableByAccount(account, this.statusWrapper);
|
||||
usableStatus
|
||||
.then((status: Status) => {
|
||||
if (this.isBoosted && status.reblogged) {
|
||||
return this.mastodonService.unreblog(account, status);
|
||||
} else if (!this.isBoosted && !status.reblogged) {
|
||||
return this.mastodonService.reblog(account, status);
|
||||
} else {
|
||||
return Promise.resolve(status);
|
||||
}
|
||||
})
|
||||
.then((boostedStatus: Status) => {
|
||||
this.bootedStatePerAccountId[account.id] = boostedStatus.reblogged;
|
||||
this.checkIfBoosted();
|
||||
})
|
||||
.catch((err: HttpErrorResponse) => {
|
||||
this.notificationService.notifyHttpError(err);
|
||||
})
|
||||
.then(() => {
|
||||
this.boostIsLoading = false;
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
favorite(): boolean {
|
||||
this.selectedAccounts.forEach((account: AccountInfo) => {
|
||||
|
||||
const usableStatus = this.toolsService.getStatusUsableByAccount(account, this.statusWrapper);
|
||||
usableStatus
|
||||
.then((status: Status) => {
|
||||
if (this.isFavorited && status.favourited) {
|
||||
return this.mastodonService.unfavorite(account, status);
|
||||
} else if(!this.isFavorited && !status.favourited) {
|
||||
return this.mastodonService.favorite(account, status);
|
||||
} else {
|
||||
return Promise.resolve(status);
|
||||
}
|
||||
})
|
||||
.then((favoritedStatus: Status) => {
|
||||
this.favoriteStatePerAccountId[account.id] = favoritedStatus.favourited;
|
||||
this.checkIfFavorited();
|
||||
// this.isFavorited = !this.isFavorited;
|
||||
})
|
||||
.catch((err: HttpErrorResponse) => {
|
||||
this.notificationService.notifyHttpError(err);
|
||||
});
|
||||
});
|
||||
if(this.favoriteIsLoading) return;
|
||||
|
||||
this.favoriteIsLoading = true;
|
||||
const account = this.toolsService.getSelectedAccounts()[0];
|
||||
const usableStatus = this.toolsService.getStatusUsableByAccount(account, this.statusWrapper);
|
||||
usableStatus
|
||||
.then((status: Status) => {
|
||||
if (this.isFavorited && status.favourited) {
|
||||
return this.mastodonService.unfavorite(account, status);
|
||||
} else if (!this.isFavorited && !status.favourited) {
|
||||
return this.mastodonService.favorite(account, status);
|
||||
} else {
|
||||
return Promise.resolve(status);
|
||||
}
|
||||
})
|
||||
.then((favoritedStatus: Status) => {
|
||||
this.favoriteStatePerAccountId[account.id] = favoritedStatus.favourited;
|
||||
this.checkIfFavorited();
|
||||
// this.isFavorited = !this.isFavorited;
|
||||
})
|
||||
.catch((err: HttpErrorResponse) => {
|
||||
this.notificationService.notifyHttpError(err);
|
||||
})
|
||||
.then(() => {
|
||||
this.favoriteIsLoading = false;
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -189,9 +199,4 @@ export class ActionBarComponent implements OnInit, OnDestroy {
|
|||
console.warn('more'); //TODO
|
||||
return false;
|
||||
}
|
||||
|
||||
// private getSelectedAccounts(): AccountInfo[] {
|
||||
// var regAccounts = <AccountInfo[]>this.store.snapshot().registeredaccounts.accounts;
|
||||
// return regAccounts;
|
||||
// }
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue