mirror of
https://github.com/Qortal/Qortal-Hub.git
synced 2025-06-01 14:16:58 +00:00
sort name- put primary on top
This commit is contained in:
parent
d43dd5465b
commit
8c2b635afb
@ -25,6 +25,7 @@ import { CustomizedSnackbars } from '../Snackbar/Snackbar';
|
|||||||
import { getFee } from '../../background';
|
import { getFee } from '../../background';
|
||||||
import { fileToBase64 } from '../../utils/fileReading';
|
import { fileToBase64 } from '../../utils/fileReading';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
|
import { useSortedMyNames } from '../../hooks/useSortedMyNames';
|
||||||
|
|
||||||
const CustomSelect = styled(Select)({
|
const CustomSelect = styled(Select)({
|
||||||
border: '0.5px solid var(--50-white, #FFFFFF80)',
|
border: '0.5px solid var(--50-white, #FFFFFF80)',
|
||||||
@ -148,7 +149,7 @@ export const AppPublish = ({ categories, myAddress, myName }) => {
|
|||||||
try {
|
try {
|
||||||
setIsLoading('Loading names');
|
setIsLoading('Loading names');
|
||||||
const res = await fetch(
|
const res = await fetch(
|
||||||
`${getBaseApiReact()}/names/address/${myAddress}`
|
`${getBaseApiReact()}/names/address/${myAddress}?limit=0`
|
||||||
);
|
);
|
||||||
const data = await res.json();
|
const data = await res.json();
|
||||||
setNames(data?.map((item) => item.name));
|
setNames(data?.map((item) => item.name));
|
||||||
@ -162,6 +163,8 @@ export const AppPublish = ({ categories, myAddress, myName }) => {
|
|||||||
getNames();
|
getNames();
|
||||||
}, [getNames]);
|
}, [getNames]);
|
||||||
|
|
||||||
|
const mySortedNames = useSortedMyNames(names, myName);
|
||||||
|
|
||||||
const publishApp = async () => {
|
const publishApp = async () => {
|
||||||
try {
|
try {
|
||||||
const data = {
|
const data = {
|
||||||
@ -329,7 +332,7 @@ export const AppPublish = ({ categories, myAddress, myName }) => {
|
|||||||
</em>
|
</em>
|
||||||
{/* This is the placeholder item */}
|
{/* This is the placeholder item */}
|
||||||
</CustomMenuItem>
|
</CustomMenuItem>
|
||||||
{names.map((name) => {
|
{mySortedNames.map((name) => {
|
||||||
return <CustomMenuItem value={name}>{name}</CustomMenuItem>;
|
return <CustomMenuItem value={name}>{name}</CustomMenuItem>;
|
||||||
})}
|
})}
|
||||||
</CustomSelect>
|
</CustomSelect>
|
||||||
|
@ -508,9 +508,9 @@ export const AppsDesktop = ({
|
|||||||
|
|
||||||
{mode === 'publish' && !selectedTab && (
|
{mode === 'publish' && !selectedTab && (
|
||||||
<AppPublish
|
<AppPublish
|
||||||
names={myName ? [myName] : []}
|
|
||||||
categories={categories}
|
categories={categories}
|
||||||
myAddress={myAddress}
|
myAddress={myAddress}
|
||||||
|
myName={myName}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
@ -43,6 +43,7 @@ import { objectToBase64 } from '../../qdn/encryption/group-encryption';
|
|||||||
import { getFee } from '../../background';
|
import { getFee } from '../../background';
|
||||||
import { useAtom } from 'jotai';
|
import { useAtom } from 'jotai';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
|
import { useSortedMyNames } from '../../hooks/useSortedMyNames';
|
||||||
|
|
||||||
const maxFileSize = 50 * 1024 * 1024; // 50MB
|
const maxFileSize = 50 * 1024 * 1024; // 50MB
|
||||||
|
|
||||||
@ -93,6 +94,8 @@ export const AppsPrivate = ({ myName, myAddress }) => {
|
|||||||
name: '',
|
name: '',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const mySortedNames = useSortedMyNames(names, myName);
|
||||||
|
|
||||||
const { getRootProps, getInputProps } = useDropzone({
|
const { getRootProps, getInputProps } = useDropzone({
|
||||||
accept: {
|
accept: {
|
||||||
'application/zip': ['.zip'], // Only accept zip files
|
'application/zip': ['.zip'], // Only accept zip files
|
||||||
@ -271,7 +274,7 @@ export const AppsPrivate = ({ myName, myAddress }) => {
|
|||||||
if (!myAddress) return;
|
if (!myAddress) return;
|
||||||
try {
|
try {
|
||||||
const res = await fetch(
|
const res = await fetch(
|
||||||
`${getBaseApiReact()}/names/address/${myAddress}`
|
`${getBaseApiReact()}/names/address/${myAddress}?limit=0`
|
||||||
);
|
);
|
||||||
const data = await res.json();
|
const data = await res.json();
|
||||||
setNames(data?.map((item) => item.name));
|
setNames(data?.map((item) => item.name));
|
||||||
@ -584,7 +587,7 @@ export const AppsPrivate = ({ myName, myAddress }) => {
|
|||||||
onChange={(e) => setName(e.target.value)}
|
onChange={(e) => setName(e.target.value)}
|
||||||
>
|
>
|
||||||
<MenuItem value={0}>No name selected</MenuItem>
|
<MenuItem value={0}>No name selected</MenuItem>
|
||||||
{names.map((name) => {
|
{mySortedNames.map((name) => {
|
||||||
return (
|
return (
|
||||||
<MenuItem key={name} value={name}>
|
<MenuItem key={name} value={name}>
|
||||||
{name}
|
{name}
|
||||||
|
11
src/hooks/useSortedMyNames.tsx
Normal file
11
src/hooks/useSortedMyNames.tsx
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
import { useMemo } from 'react';
|
||||||
|
|
||||||
|
export function useSortedMyNames(names, myName) {
|
||||||
|
return useMemo(() => {
|
||||||
|
return [...names].sort((a, b) => {
|
||||||
|
if (a === myName) return -1;
|
||||||
|
if (b === myName) return 1;
|
||||||
|
return 0;
|
||||||
|
});
|
||||||
|
}, [names, myName]);
|
||||||
|
}
|
@ -1442,7 +1442,6 @@ export const publishMultipleQDNResources = async (
|
|||||||
if (resource?.file) {
|
if (resource?.file) {
|
||||||
rawData = await fileToBase64(resource.file);
|
rawData = await fileToBase64(resource.file);
|
||||||
}
|
}
|
||||||
console.log('encrypteddata', rawData);
|
|
||||||
const resKeyPair = await getKeyPair();
|
const resKeyPair = await getKeyPair();
|
||||||
const parsedData = resKeyPair;
|
const parsedData = resKeyPair;
|
||||||
const privateKey = parsedData.privateKey;
|
const privateKey = parsedData.privateKey;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user