diff --git a/src/app/components/stream/status/action-bar/action-bar.component.html b/src/app/components/stream/status/action-bar/action-bar.component.html
index 7d93a47e..7595c7f9 100644
--- a/src/app/components/stream/status/action-bar/action-bar.component.html
+++ b/src/app/components/stream/status/action-bar/action-bar.component.html
@@ -1,11 +1,11 @@
-
+
-
+
-
+
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 e3a8a3ce..356a5f58 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
@@ -1,29 +1,71 @@
-import { Component, OnInit, Input } from '@angular/core';
+import { Component, OnInit, OnDestroy, Input } from '@angular/core';
import { Store } from '@ngxs/store';
import { StatusWrapper } from '../../stream.component';
import { MastodonService } from '../../../../services/mastodon.service';
import { AccountInfo } from '../../../../states/accounts.state';
+import { Observable, Subscription } from 'rxjs';
+// import { map } from "rxjs/operators";
@Component({
selector: 'app-action-bar',
templateUrl: './action-bar.component.html',
styleUrls: ['./action-bar.component.scss']
})
-export class ActionBarComponent implements OnInit {
+export class ActionBarComponent implements OnInit, OnDestroy {
+
@Input() statusWrapper: StatusWrapper;
isFavorited: boolean;
isBoosted: boolean;
-
+
isBoostLocked: boolean;
isLocked: boolean;
+ private isProviderSelected: boolean;
+ private selectedAccounts: AccountInfo[];
+
+ private accounts$: Observable;
+ private accountSub: Subscription;
+
constructor(
private readonly store: Store,
- private readonly mastodonService: MastodonService) { }
+ private readonly mastodonService: MastodonService) {
- ngOnInit() {
+ this.accounts$ = this.store.select(state => state.registeredaccounts.accounts);
+ }
+
+ ngOnInit() {
+ // const selectedAccounts = this.getSelectedAccounts();
+ // this.checkStatus(selectedAccounts);
+
+ this.accountSub = this.accounts$.subscribe((accounts: AccountInfo[]) => {
+ console.warn('selectedAccounts');
+ this.checkStatus(accounts);
+ });
+ }
+
+ ngOnDestroy(): void {
+ this.accountSub.unsubscribe();
+ }
+
+ private checkStatus(accounts: AccountInfo[]): void {
+ const status = this.statusWrapper.status;
+ const provider = this.statusWrapper.provider;
+ this.selectedAccounts = accounts.filter(x => x.isSelected);
+ this.isProviderSelected = this.selectedAccounts.filter(x => x.id === provider.id).length > 0;
+
+ if (status.visibility === 'direct' || status.visibility === 'private') {
+ this.isBoostLocked = true;
+ } else {
+ this.isBoostLocked = false;
+ }
+
+ if ((status.visibility === 'direct' || status.visibility === 'private') && !this.isProviderSelected) {
+ this.isLocked = true;
+ } else {
+ this.isLocked = false;
+ }
}
reply(): boolean {
@@ -32,6 +74,9 @@ export class ActionBarComponent implements OnInit {
}
boost(): boolean {
+
+
+
console.warn('boost');
this.isBoosted = !this.isBoosted;
return false;
@@ -50,6 +95,6 @@ export class ActionBarComponent implements OnInit {
private getSelectedAccounts(): AccountInfo[] {
var regAccounts = this.store.snapshot().registeredaccounts.accounts;
- return regAccounts.filter(x => x.isSelected);
+ return regAccounts;
}
}