From 71ab20ffa94dbd9c1853a16f4f84ebac0fc18046 Mon Sep 17 00:00:00 2001 From: NickJ202 Date: Fri, 21 Jun 2024 13:01:25 -0400 Subject: [PATCH] catch gateway delay on upload / add multiline string support for title --- src/components/atoms/Button/styles.ts | 2 +- src/components/molecules/Table/styles.ts | 6 +- src/helpers/language.ts | 2 +- src/views/Upload/index.tsx | 147 ++++++++++++----------- 4 files changed, 82 insertions(+), 75 deletions(-) diff --git a/src/components/atoms/Button/styles.ts b/src/components/atoms/Button/styles.ts index 5324ff5..2872567 100644 --- a/src/components/atoms/Button/styles.ts +++ b/src/components/atoms/Button/styles.ts @@ -146,7 +146,7 @@ export const Alt1 = styled(Primary)` width: fit-content; text-overflow: ellipsis; overflow: hidden; - font-size: ${(props) => props.theme.typography.size.small} !important; + font-size: ${(props) => props.theme.typography.size.xSmall} !important; font-weight: ${(props) => props.theme.typography.weight.bold} !important; color: ${(props) => props.theme.colors.font.light1} !important; } diff --git a/src/components/molecules/Table/styles.ts b/src/components/molecules/Table/styles.ts index 6c36f26..d7c0cf0 100644 --- a/src/components/molecules/Table/styles.ts +++ b/src/components/molecules/Table/styles.ts @@ -1,4 +1,4 @@ -import styled, { theme } from 'styled-components'; +import styled from 'styled-components'; import { fadeIn2, open } from 'helpers/animations'; import { STYLING } from 'helpers/config'; @@ -80,7 +80,7 @@ export const TableHeader = styled.div` overflow: hidden; `; -function getRowStyle(theme: theme, active: boolean, viewed: boolean) { +function getRowStyle(theme: any, active: boolean, viewed: boolean) { if (active) { return ` background: ${theme.colors.table.row.active.background}; @@ -122,7 +122,7 @@ export const RowData = styled.div` font-size: ${(props) => props.theme.typography.size.xSmall}; font-weight: ${(props) => props.theme.typography.weight.bold}; color: ${(props) => props.theme.colors.font.primary}; - overflow: visible; + overflow: hidden; text-overflow: ellipsis; white-space: nowrap; height: 20px; diff --git a/src/helpers/language.ts b/src/helpers/language.ts index 8be65db..4755241 100644 --- a/src/helpers/language.ts +++ b/src/helpers/language.ts @@ -9,7 +9,7 @@ export const language = { arweaveAppUploadBlocked: `Arweave.app is not supported for upload`, assets: `Assets`, assetsCreated: `Assets created`, - assetsCreatedInfo: `Your assets have been created. It may take some time for them to be available from your profile.`, + assetsCreatedInfo: `Your assets have been created. You will now be able to view them from your profile.`, assetDetails: `Asset details`, assetExists: `An asset with this name already exists`, assetFetchConnectionRequired: `Connect a wallet to view your assets`, diff --git a/src/views/Upload/index.tsx b/src/views/Upload/index.tsx index 6f06730..6124f77 100644 --- a/src/views/Upload/index.tsx +++ b/src/views/Upload/index.tsx @@ -132,7 +132,6 @@ export default function Upload() { break; } dispatch(uploadActions.setUploadActive(false)); - dispatch(uploadActions.setUploadActive(false)); dispatch(uploadActions.clearUpload()); setUploadPercentage(0); } @@ -259,52 +258,56 @@ export default function Upload() { } } - const evalMessage = await aos.message({ - process: processId, - signer: createDataItemSigner(globalThis.arweaveWallet), - tags: [{ name: 'Action', value: 'Eval' }], - data: processSrc, - }); + if (fetchedCollectionId) { + const evalMessage = await aos.message({ + process: processId, + signer: createDataItemSigner(globalThis.arweaveWallet), + tags: [{ name: 'Action', value: 'Eval' }], + data: processSrc, + }); - const evalResult = await aos.result({ - message: evalMessage, - process: processId, - }); + const evalResult = await aos.result({ + message: evalMessage, + process: processId, + }); - if (evalResult) { - const registryTags = [ - { name: 'Action', value: 'Add-Collection' }, - { name: 'CollectionId', value: processId }, - { name: 'Name', value: uploadReducer.data.title }, - { name: 'Creator', value: arProvider.profile.id }, - { name: 'DateCreated', value: dateTime }, - ]; + if (evalResult) { + const registryTags = [ + { name: 'Action', value: 'Add-Collection' }, + { name: 'CollectionId', value: processId }, + { name: 'Name', value: uploadReducer.data.title }, + { name: 'Creator', value: arProvider.profile.id }, + { name: 'DateCreated', value: dateTime }, + ]; - if (bannerTx) registryTags.push({ name: 'Banner', value: bannerTx }); - if (thumbnailTx) registryTags.push({ name: 'Thumbnail', value: thumbnailTx }); + if (bannerTx) registryTags.push({ name: 'Banner', value: bannerTx }); + if (thumbnailTx) registryTags.push({ name: 'Thumbnail', value: thumbnailTx }); - const updateRegistryResponse = await aos.message({ - process: AOS.collectionsRegistry, - signer: createDataItemSigner(globalThis.arweaveWallet), - tags: registryTags, - }); + const updateRegistryResponse = await aos.message({ + process: AOS.collectionsRegistry, + signer: createDataItemSigner(globalThis.arweaveWallet), + tags: registryTags, + }); - console.log(updateRegistryResponse); + console.log(updateRegistryResponse); - const profileCollectionsUpdate = await aos.message({ - process: processId, - signer: createDataItemSigner(globalThis.arweaveWallet), - tags: [ - { name: 'Action', value: 'Add-Collection-To-Profile' }, - { name: 'ProfileProcess', value: arProvider.profile.id }, - ], - }); + const profileCollectionsUpdate = await aos.message({ + process: processId, + signer: createDataItemSigner(globalThis.arweaveWallet), + tags: [ + { name: 'Action', value: 'Add-Collection-To-Profile' }, + { name: 'ProfileProcess', value: arProvider.profile.id }, + ], + }); - console.log(profileCollectionsUpdate); + console.log(profileCollectionsUpdate); - return processId; + return processId; + } else { + return null; + } } else { - return null; + setCollectionResponseError('Error fetching from gateway'); } } catch (e: any) { console.error(e); @@ -375,7 +378,7 @@ export default function Upload() { if (processSrc) { processSrc = processSrc.replace('[Owner]', `['${arProvider.profile.id}']`); - processSrc = processSrc.replaceAll('', title); + processSrc = processSrc.replaceAll(`''`, `[[${title}]]`); processSrc = processSrc.replaceAll('', 'ATOMIC'); processSrc = processSrc.replaceAll('', '1'); processSrc = processSrc.replaceAll('', balance.toString()); @@ -415,43 +418,47 @@ export default function Upload() { } } - const evalMessage = await aos.message({ - process: processId, - signer: createDataItemSigner(globalThis.arweaveWallet), - tags: [{ name: 'Action', value: 'Eval' }], - data: processSrc, - }); - - const evalResult = await aos.result({ - message: evalMessage, - process: processId, - }); - - if (evalResult) { - // const updateProfileResponse = await aos.message({ - // process: arProvider.profile.id, - // signer: createDataItemSigner(globalThis.arweaveWallet), - // tags: [{ name: 'Action', value: 'Add-Uploaded-Asset' }], - // data: JSON.stringify({ Id: processId, Quantity: balance }), - // }); - - const updateProfileResponse = await aos.message({ + if (fetchedAssetId) { + const evalMessage = await aos.message({ process: processId, signer: createDataItemSigner(globalThis.arweaveWallet), - tags: [ - { name: 'Action', value: 'Add-Asset-To-Profile' }, - { name: 'ProfileProcess', value: arProvider.profile.id }, - { name: 'Quantity', value: balance.toString() }, - ], - data: JSON.stringify({ Id: processId, Quantity: balance }), + tags: [{ name: 'Action', value: 'Eval' }], + data: processSrc, }); - console.log(updateProfileResponse); + const evalResult = await aos.result({ + message: evalMessage, + process: processId, + }); - uploadedAssetsList.push(processId); - } + if (evalResult) { + // const updateProfileResponse = await aos.message({ + // process: arProvider.profile.id, + // signer: createDataItemSigner(globalThis.arweaveWallet), + // tags: [{ name: 'Action', value: 'Add-Uploaded-Asset' }], + // data: JSON.stringify({ Id: processId, Quantity: balance }), + // }); + + const updateProfileResponse = await aos.message({ + process: processId, + signer: createDataItemSigner(globalThis.arweaveWallet), + tags: [ + { name: 'Action', value: 'Add-Asset-To-Profile' }, + { name: 'ProfileProcess', value: arProvider.profile.id }, + { name: 'Quantity', value: balance.toString() }, + ], + data: JSON.stringify({ Id: processId, Quantity: balance }), + }); - if (index < uploadReducer.data.contentList.length) setUploadPercentage(0); + console.log(updateProfileResponse); + + uploadedAssetsList.push(processId); + } + + if (index < uploadReducer.data.contentList.length) setUploadPercentage(0); + } else { + setAssetsResponseError('Error fetching from gateway'); + } } catch (e: any) { console.error(e.message); assetError = e.message;