From 3a0dc99783ceaae6c553b0a95a84b2df27d4a7fc Mon Sep 17 00:00:00 2001 From: Nicolas Constant Date: Fri, 22 Feb 2019 23:48:02 -0500 Subject: [PATCH] updating relationships when changing accounts --- .../user-profile/user-profile.component.scss | 1 + .../user-profile/user-profile.component.ts | 27 ++++++++++--------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/app/components/stream/user-profile/user-profile.component.scss b/src/app/components/stream/user-profile/user-profile.component.scss index ee9befd5..804e1999 100644 --- a/src/app/components/stream/user-profile/user-profile.component.scss +++ b/src/app/components/stream/user-profile/user-profile.component.scss @@ -47,6 +47,7 @@ $header-height: 160px; color: white; } &__follow{ + // transition: all .4s; position: absolute; top: 10px; right: 15px; diff --git a/src/app/components/stream/user-profile/user-profile.component.ts b/src/app/components/stream/user-profile/user-profile.component.ts index 68d268ab..1672f157 100644 --- a/src/app/components/stream/user-profile/user-profile.component.ts +++ b/src/app/components/stream/user-profile/user-profile.component.ts @@ -46,10 +46,8 @@ export class UserProfileComponent implements OnInit { @Output() browseThreadEvent = new EventEmitter(); @Input('currentAccount') - //set currentAccount(account: Account) { set currentAccount(accountName: string) { - this.lastAccountName = accountName; - this.load(this.lastAccountName); + this.load(accountName); } constructor( @@ -62,10 +60,11 @@ export class UserProfileComponent implements OnInit { } ngOnInit() { - // this.currentlyUsedAccount = this.toolsService.getSelectedAccounts()[0]; this.accountSub = this.accounts$.subscribe((accounts: AccountInfo[]) => { - const userAccount = accounts.filter(x => x.isSelected)[0]; - // this.load() + if (this.account) { + const userAccount = accounts.filter(x => x.isSelected)[0]; + this.getFollowStatus(userAccount, this.account); + } }); } @@ -78,12 +77,14 @@ export class UserProfileComponent implements OnInit { this.account = null; this.isLoading = true; - this.statusLoading = true; - this.currentlyUsedAccount = this.toolsService.getSelectedAccounts()[0]; + this.lastAccountName = accountName; + this.currentlyUsedAccount = this.toolsService.getSelectedAccounts()[0]; + return this.toolsService.findAccount(this.currentlyUsedAccount, accountName) .then((account: Account) => { this.isLoading = false; + this.statusLoading = true; this.account = account; this.hasNote = account && account.note && account.note !== '

'; @@ -101,7 +102,7 @@ export class UserProfileComponent implements OnInit { this.statusLoading = false; }); } - + private getStatuses(userAccount: AccountInfo, account: Account): Promise { this.statusLoading = true; return this.mastodonService.getAccountStatuses(userAccount, account.id, false, false, true, null, null, 40) @@ -112,12 +113,12 @@ export class UserProfileComponent implements OnInit { } this.statusLoading = false; }); - } + } - private getFollowStatus(userAccount: AccountInfo, account: Account):Promise { + private getFollowStatus(userAccount: AccountInfo, account: Account): Promise { this.relationship = null; return this.mastodonService.getRelationships(userAccount, [account]) - .then((result: Relationship[])=> { + .then((result: Relationship[]) => { this.relationship = result.filter(x => x.id === account.id)[0]; }); } @@ -136,5 +137,5 @@ export class UserProfileComponent implements OnInit { browseThread(openThreadEvent: OpenThreadEvent): void { this.browseThreadEvent.next(openThreadEvent); - } + } }