utils/accounts: pick only needed fields from type

This commit is contained in:
Alex Gleason 2023-06-19 12:10:29 -05:00
parent 060a9b559d
commit 8a4239d153
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7

View file

@ -1,7 +1,7 @@
import type { Account } from 'soapbox/schemas';
import type { Account as AccountEntity } from 'soapbox/types/entities';
const getDomainFromURL = (account: AccountEntity): string => {
const getDomainFromURL = (account: Pick<AccountEntity, 'url'>): string => {
try {
const url = account.url;
return new URL(url).host;
@ -10,7 +10,7 @@ const getDomainFromURL = (account: AccountEntity): string => {
}
};
export const getDomain = (account: AccountEntity): string => {
export const getDomain = (account: Pick<AccountEntity, 'acct' | 'url'>): string => {
const domain = account.acct.split('@')[1];
return domain ? domain : getDomainFromURL(account);
};