diff --git a/src/components/Apps/AppPublish.tsx b/src/components/Apps/AppPublish.tsx index b1565b9..6ac7e76 100644 --- a/src/components/Apps/AppPublish.tsx +++ b/src/components/Apps/AppPublish.tsx @@ -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 }) => { {/* This is the placeholder item */} - {names.map((name) => { + {mySortedNames.map((name) => { return {name}; })} diff --git a/src/components/Apps/AppsDesktop.tsx b/src/components/Apps/AppsDesktop.tsx index bca16cb..1cc6d0d 100644 --- a/src/components/Apps/AppsDesktop.tsx +++ b/src/components/Apps/AppsDesktop.tsx @@ -508,9 +508,9 @@ export const AppsDesktop = ({ {mode === 'publish' && !selectedTab && ( )} diff --git a/src/components/Apps/AppsPrivate.tsx b/src/components/Apps/AppsPrivate.tsx index 54f785c..a9f8d45 100644 --- a/src/components/Apps/AppsPrivate.tsx +++ b/src/components/Apps/AppsPrivate.tsx @@ -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)} > No name selected - {names.map((name) => { + {mySortedNames.map((name) => { return ( {name} diff --git a/src/hooks/useSortedMyNames.tsx b/src/hooks/useSortedMyNames.tsx new file mode 100644 index 0000000..6fb8917 --- /dev/null +++ b/src/hooks/useSortedMyNames.tsx @@ -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]); +} diff --git a/src/qortalRequests/get.ts b/src/qortalRequests/get.ts index 0020a09..034180a 100644 --- a/src/qortalRequests/get.ts +++ b/src/qortalRequests/get.ts @@ -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;