mirror of
https://github.com/Qortal/Qortal-Hub.git
synced 2025-06-02 22:46:59 +00:00
fetch primary name
This commit is contained in:
parent
388e44e4e7
commit
88d624c003
@ -805,9 +805,9 @@ export async function getNameInfo() {
|
||||
const wallet = await getSaveWallet();
|
||||
const address = wallet.address0;
|
||||
const validApi = await getBaseApi();
|
||||
const response = await fetch(validApi + '/names/address/' + address);
|
||||
const response = await fetch(validApi + '/names/primary/' + address);
|
||||
const nameData = await response.json();
|
||||
if (nameData?.length > 0) {
|
||||
if (nameData?.name) {
|
||||
return nameData[0].name;
|
||||
} else {
|
||||
return '';
|
||||
@ -815,11 +815,12 @@ export async function getNameInfo() {
|
||||
}
|
||||
|
||||
export async function getNameInfoForOthers(address) {
|
||||
if (!address) return '';
|
||||
const validApi = await getBaseApi();
|
||||
const response = await fetch(validApi + '/names/address/' + address);
|
||||
const response = await fetch(validApi + '/names/primary/' + address);
|
||||
const nameData = await response.json();
|
||||
if (nameData?.length > 0) {
|
||||
return nameData[0].name;
|
||||
if (nameData?.name) {
|
||||
return nameData?.name;
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
|
@ -265,11 +265,11 @@ export const getDataPublishesFunc = async (groupId, type) => {
|
||||
};
|
||||
|
||||
export async function getNameInfo(address: string) {
|
||||
const response = await fetch(`${getBaseApiReact()}/names/address/` + address);
|
||||
const response = await fetch(`${getBaseApiReact()}/names/primary/` + address);
|
||||
const nameData = await response.json();
|
||||
|
||||
if (nameData?.length > 0) {
|
||||
return nameData[0]?.name;
|
||||
if (nameData?.name) {
|
||||
return nameData?.name;
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
|
@ -85,14 +85,14 @@ export const Minting = ({ setIsOpenMinting, myAddress, show }) => {
|
||||
const getName = async (address) => {
|
||||
try {
|
||||
const response = await fetch(
|
||||
`${getBaseApiReact()}/names/address/${address}`
|
||||
`${getBaseApiReact()}/names/primary/${address}`
|
||||
);
|
||||
const nameData = await response.json();
|
||||
if (nameData?.length > 0) {
|
||||
if (nameData?.name) {
|
||||
setNames((prev) => {
|
||||
return {
|
||||
...prev,
|
||||
[address]: nameData[0].name,
|
||||
[address]: nameData?.name,
|
||||
};
|
||||
});
|
||||
} else {
|
||||
|
@ -26,10 +26,10 @@ export async function getNameInfo() {
|
||||
const wallet = await getSaveWallet();
|
||||
const address = wallet.address0;
|
||||
const validApi = await getBaseApi();
|
||||
const response = await fetch(validApi + '/names/address/' + address);
|
||||
const response = await fetch(validApi + '/names/primary/' + address);
|
||||
const nameData = await response.json();
|
||||
if (nameData?.length > 0) {
|
||||
return nameData[0].name;
|
||||
if (nameData?.name) {
|
||||
return nameData?.name;
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
|
@ -256,6 +256,7 @@ export const listOfAllQortalRequests = [
|
||||
'UPDATE_GROUP',
|
||||
'UPDATE_NAME',
|
||||
'VOTE_ON_POLL',
|
||||
'GET_PRIMARY_NAME',
|
||||
];
|
||||
|
||||
export const UIQortalRequests = [
|
||||
@ -319,6 +320,7 @@ export const UIQortalRequests = [
|
||||
'UPDATE_GROUP',
|
||||
'UPDATE_NAME',
|
||||
'VOTE_ON_POLL',
|
||||
'GET_PRIMARY_NAME',
|
||||
];
|
||||
|
||||
async function retrieveFileFromIndexedDB(fileId) {
|
||||
|
@ -317,7 +317,7 @@ export const publishData = async ({
|
||||
}
|
||||
|
||||
const file = data;
|
||||
const urlCheck = `/arbitrary/check-tmp-space?totalSize=${file.size}`;
|
||||
const urlCheck = `/arbitrary/check/tmp?totalSize=${file.size}`;
|
||||
|
||||
const checkEndpoint = await createEndpoint(urlCheck);
|
||||
const checkRes = await fetch(checkEndpoint);
|
||||
|
@ -1,4 +1,8 @@
|
||||
import { gateways, getApiKeyFromStorage } from '../background/background.ts';
|
||||
import {
|
||||
gateways,
|
||||
getApiKeyFromStorage,
|
||||
getNameInfoForOthers,
|
||||
} from '../background/background.ts';
|
||||
import { listOfAllQortalRequests } from '../hooks/useQortalMessageListener.tsx';
|
||||
import {
|
||||
addForeignServer,
|
||||
@ -1932,6 +1936,33 @@ function setupMessageListenerQortalRequest() {
|
||||
break;
|
||||
}
|
||||
|
||||
case 'GET_PRIMARY_NAME': {
|
||||
try {
|
||||
const res = await getNameInfoForOthers(request.payload?.address);
|
||||
const resData = res ? res : null;
|
||||
event.source.postMessage(
|
||||
{
|
||||
requestId: request.requestId,
|
||||
action: request.action,
|
||||
payload: resData,
|
||||
type: 'backgroundMessageResponse',
|
||||
},
|
||||
event.origin
|
||||
);
|
||||
} catch (error) {
|
||||
event.source.postMessage(
|
||||
{
|
||||
requestId: request.requestId,
|
||||
action: request.action,
|
||||
error: error.message,
|
||||
type: 'backgroundMessageResponse',
|
||||
},
|
||||
event.origin
|
||||
);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user