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