forked from Qortal/q-tube
Use PrimaryName Qortal Request instead of names[0]
This commit is contained in:
@@ -41,6 +41,14 @@ export const getAccountNames = async (
|
||||
return emptyNamesFilled.length > 0 ? emptyNamesFilled : [namelessAddress];
|
||||
};
|
||||
|
||||
export const getPrimaryAccountName = async (address: string) => {
|
||||
const primaryName = (await qortalRequest({
|
||||
action: "GET_PRIMARY_NAME",
|
||||
address,
|
||||
})) as string;
|
||||
return primaryName.length > 0 ? primaryName : "";
|
||||
}
|
||||
|
||||
export const searchTransactions = async (params: TransactionSearchParams) => {
|
||||
return (await qortalRequest({
|
||||
action: "SEARCH_TRANSACTIONS",
|
||||
|
||||
@@ -93,27 +93,13 @@ const GlobalWrapper: React.FC<Props> = ({ children, setTheme }) => {
|
||||
|
||||
const { isLoadingGlobal } = useSelector((state: RootState) => state.global);
|
||||
|
||||
async function getNameInfo(address: string) {
|
||||
const response = await qortalRequest({
|
||||
action: "GET_ACCOUNT_NAMES",
|
||||
address: address,
|
||||
});
|
||||
const nameData = response;
|
||||
|
||||
if (nameData?.length > 0) {
|
||||
return nameData[0].name;
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
const askForAccountInformation = React.useCallback(async () => {
|
||||
try {
|
||||
const account = await qortalRequest({
|
||||
action: "GET_USER_ACCOUNT",
|
||||
});
|
||||
|
||||
const name = await getNameInfo(account.address);
|
||||
const name = getPrimaryAccountName(account.address);
|
||||
dispatch(addUser({ ...account, name }));
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
|
||||
Reference in New Issue
Block a user