updating relationships when changing accounts

This commit is contained in:
Nicolas Constant 2019-02-22 23:48:02 -05:00
parent f447f9c493
commit 3a0dc99783
No known key found for this signature in database
GPG Key ID: 1E9F677FB01A5688
2 changed files with 15 additions and 13 deletions

View File

@ -47,6 +47,7 @@ $header-height: 160px;
color: white; color: white;
} }
&__follow{ &__follow{
// transition: all .4s;
position: absolute; position: absolute;
top: 10px; top: 10px;
right: 15px; right: 15px;

View File

@ -46,10 +46,8 @@ export class UserProfileComponent implements OnInit {
@Output() browseThreadEvent = new EventEmitter<OpenThreadEvent>(); @Output() browseThreadEvent = new EventEmitter<OpenThreadEvent>();
@Input('currentAccount') @Input('currentAccount')
//set currentAccount(account: Account) {
set currentAccount(accountName: string) { set currentAccount(accountName: string) {
this.lastAccountName = accountName; this.load(accountName);
this.load(this.lastAccountName);
} }
constructor( constructor(
@ -62,10 +60,11 @@ export class UserProfileComponent implements OnInit {
} }
ngOnInit() { ngOnInit() {
// this.currentlyUsedAccount = this.toolsService.getSelectedAccounts()[0];
this.accountSub = this.accounts$.subscribe((accounts: AccountInfo[]) => { this.accountSub = this.accounts$.subscribe((accounts: AccountInfo[]) => {
const userAccount = accounts.filter(x => x.isSelected)[0]; if (this.account) {
// this.load() 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.account = null;
this.isLoading = true; 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) return this.toolsService.findAccount(this.currentlyUsedAccount, accountName)
.then((account: Account) => { .then((account: Account) => {
this.isLoading = false; this.isLoading = false;
this.statusLoading = true;
this.account = account; this.account = account;
this.hasNote = account && account.note && account.note !== '<p></p>'; this.hasNote = account && account.note && account.note !== '<p></p>';
@ -101,7 +102,7 @@ export class UserProfileComponent implements OnInit {
this.statusLoading = false; this.statusLoading = false;
}); });
} }
private getStatuses(userAccount: AccountInfo, account: Account): Promise<void> { private getStatuses(userAccount: AccountInfo, account: Account): Promise<void> {
this.statusLoading = true; this.statusLoading = true;
return this.mastodonService.getAccountStatuses(userAccount, account.id, false, false, true, null, null, 40) 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; this.statusLoading = false;
}); });
} }
private getFollowStatus(userAccount: AccountInfo, account: Account):Promise<void> { private getFollowStatus(userAccount: AccountInfo, account: Account): Promise<void> {
this.relationship = null; this.relationship = null;
return this.mastodonService.getRelationships(userAccount, [account]) return this.mastodonService.getRelationships(userAccount, [account])
.then((result: Relationship[])=> { .then((result: Relationship[]) => {
this.relationship = result.filter(x => x.id === account.id)[0]; this.relationship = result.filter(x => x.id === account.id)[0];
}); });
} }
@ -136,5 +137,5 @@ export class UserProfileComponent implements OnInit {
browseThread(openThreadEvent: OpenThreadEvent): void { browseThread(openThreadEvent: OpenThreadEvent): void {
this.browseThreadEvent.next(openThreadEvent); this.browseThreadEvent.next(openThreadEvent);
} }
} }