Skip to content

Commit

Permalink
catch gateway delay on upload / add multiline string support for title
Browse files Browse the repository at this point in the history
  • Loading branch information
NickJ202 committed Jun 21, 2024
1 parent e3d8400 commit 71ab20f
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 75 deletions.
2 changes: 1 addition & 1 deletion src/components/atoms/Button/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
6 changes: 3 additions & 3 deletions src/components/molecules/Table/styles.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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};
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/language.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`,
Expand Down
147 changes: 77 additions & 70 deletions src/views/Upload/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ export default function Upload() {
break;
}
dispatch(uploadActions.setUploadActive(false));
dispatch(uploadActions.setUploadActive(false));
dispatch(uploadActions.clearUpload());
setUploadPercentage(0);
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -375,7 +378,7 @@ export default function Upload() {

if (processSrc) {
processSrc = processSrc.replace('[Owner]', `['${arProvider.profile.id}']`);
processSrc = processSrc.replaceAll('<NAME>', title);
processSrc = processSrc.replaceAll(`'<NAME>'`, `[[${title}]]`);
processSrc = processSrc.replaceAll('<TICKER>', 'ATOMIC');
processSrc = processSrc.replaceAll('<DENOMINATION>', '1');
processSrc = processSrc.replaceAll('<BALANCE>', balance.toString());
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 71ab20f

Please sign in to comment.