ensure account returned is matching acct fix #23
This commit is contained in:
parent
2d4768e2b0
commit
6428ee927e
@ -76,11 +76,10 @@ export class UserProfileComponent implements OnInit {
|
||||
}
|
||||
|
||||
this.isLoading = true;
|
||||
return this.mastodonService.search(selectedAccounts[0], accountName, true)
|
||||
.then((result: Results) => {
|
||||
console.warn(result);
|
||||
return this.toolsService.findAccount(selectedAccounts[0], accountName)
|
||||
.then((result) => {
|
||||
this.isLoading = false;
|
||||
return result.accounts[0];
|
||||
return result;
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,8 @@ import { Injectable } from '@angular/core';
|
||||
import { Store } from '@ngxs/store';
|
||||
|
||||
import { AccountInfo } from '../states/accounts.state';
|
||||
import { MastodonService } from './mastodon.service';
|
||||
import { Account, Results } from "./models/mastodon.interfaces";
|
||||
|
||||
|
||||
@Injectable({
|
||||
@ -9,7 +11,9 @@ import { AccountInfo } from '../states/accounts.state';
|
||||
})
|
||||
export class ToolsService {
|
||||
|
||||
constructor( private readonly store: Store) { }
|
||||
constructor(
|
||||
private readonly mastodonService: MastodonService,
|
||||
private readonly store: Store) { }
|
||||
|
||||
|
||||
getSelectedAccounts(): AccountInfo[] {
|
||||
@ -17,4 +21,19 @@ export class ToolsService {
|
||||
return regAccounts.filter(x => x.isSelected);
|
||||
}
|
||||
|
||||
findAccount(account: AccountInfo, accountName: string): Promise<Account> {
|
||||
return this.mastodonService.search(account, accountName, true)
|
||||
.then((result: Results) => {
|
||||
console.warn('findAccount');
|
||||
console.warn(`accountName ${accountName}`);
|
||||
console.warn(result);
|
||||
|
||||
const foundAccount = result.accounts.filter(
|
||||
x => x.acct.toLowerCase() === accountName.toLowerCase()
|
||||
|| x.acct.toLowerCase() === accountName.toLowerCase().split('@')[0]
|
||||
)[0];
|
||||
return foundAccount;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user