mirror of
https://github.com/Qortal/Qortal-Hub.git
synced 2025-06-06 08:26:58 +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 wallet = await getSaveWallet();
|
||||||
const address = wallet.address0;
|
const address = wallet.address0;
|
||||||
const validApi = await getBaseApi();
|
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();
|
const nameData = await response.json();
|
||||||
if (nameData?.length > 0) {
|
if (nameData?.name) {
|
||||||
return nameData[0].name;
|
return nameData[0].name;
|
||||||
} else {
|
} else {
|
||||||
return '';
|
return '';
|
||||||
@ -815,11 +815,12 @@ export async function getNameInfo() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function getNameInfoForOthers(address) {
|
export async function getNameInfoForOthers(address) {
|
||||||
|
if (!address) return '';
|
||||||
const validApi = await getBaseApi();
|
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();
|
const nameData = await response.json();
|
||||||
if (nameData?.length > 0) {
|
if (nameData?.name) {
|
||||||
return nameData[0].name;
|
return nameData?.name;
|
||||||
} else {
|
} else {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
@ -265,11 +265,11 @@ export const getDataPublishesFunc = async (groupId, type) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export async function getNameInfo(address: string) {
|
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();
|
const nameData = await response.json();
|
||||||
|
|
||||||
if (nameData?.length > 0) {
|
if (nameData?.name) {
|
||||||
return nameData[0]?.name;
|
return nameData?.name;
|
||||||
} else {
|
} else {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
@ -85,14 +85,14 @@ export const Minting = ({ setIsOpenMinting, myAddress, show }) => {
|
|||||||
const getName = async (address) => {
|
const getName = async (address) => {
|
||||||
try {
|
try {
|
||||||
const response = await fetch(
|
const response = await fetch(
|
||||||
`${getBaseApiReact()}/names/address/${address}`
|
`${getBaseApiReact()}/names/primary/${address}`
|
||||||
);
|
);
|
||||||
const nameData = await response.json();
|
const nameData = await response.json();
|
||||||
if (nameData?.length > 0) {
|
if (nameData?.name) {
|
||||||
setNames((prev) => {
|
setNames((prev) => {
|
||||||
return {
|
return {
|
||||||
...prev,
|
...prev,
|
||||||
[address]: nameData[0].name,
|
[address]: nameData?.name,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
@ -26,10 +26,10 @@ export async function getNameInfo() {
|
|||||||
const wallet = await getSaveWallet();
|
const wallet = await getSaveWallet();
|
||||||
const address = wallet.address0;
|
const address = wallet.address0;
|
||||||
const validApi = await getBaseApi();
|
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();
|
const nameData = await response.json();
|
||||||
if (nameData?.length > 0) {
|
if (nameData?.name) {
|
||||||
return nameData[0].name;
|
return nameData?.name;
|
||||||
} else {
|
} else {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
@ -256,6 +256,7 @@ export const listOfAllQortalRequests = [
|
|||||||
'UPDATE_GROUP',
|
'UPDATE_GROUP',
|
||||||
'UPDATE_NAME',
|
'UPDATE_NAME',
|
||||||
'VOTE_ON_POLL',
|
'VOTE_ON_POLL',
|
||||||
|
'GET_PRIMARY_NAME',
|
||||||
];
|
];
|
||||||
|
|
||||||
export const UIQortalRequests = [
|
export const UIQortalRequests = [
|
||||||
@ -319,6 +320,7 @@ export const UIQortalRequests = [
|
|||||||
'UPDATE_GROUP',
|
'UPDATE_GROUP',
|
||||||
'UPDATE_NAME',
|
'UPDATE_NAME',
|
||||||
'VOTE_ON_POLL',
|
'VOTE_ON_POLL',
|
||||||
|
'GET_PRIMARY_NAME',
|
||||||
];
|
];
|
||||||
|
|
||||||
async function retrieveFileFromIndexedDB(fileId) {
|
async function retrieveFileFromIndexedDB(fileId) {
|
||||||
|
@ -317,7 +317,7 @@ export const publishData = async ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const file = data;
|
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 checkEndpoint = await createEndpoint(urlCheck);
|
||||||
const checkRes = await fetch(checkEndpoint);
|
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 { listOfAllQortalRequests } from '../hooks/useQortalMessageListener.tsx';
|
||||||
import {
|
import {
|
||||||
addForeignServer,
|
addForeignServer,
|
||||||
@ -1932,6 +1936,33 @@ function setupMessageListenerQortalRequest() {
|
|||||||
break;
|
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:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user