diff --git a/api/ipfs/utils.py b/api/ipfs/utils.py index 2d4309e..fc76c3f 100644 --- a/api/ipfs/utils.py +++ b/api/ipfs/utils.py @@ -18,11 +18,13 @@ def pin_image(imageFile, imageName): suffix = imageName.split('.').pop() try: - with NamedTemporaryFile(suffix=f".{suffix}", delete=True) as temp_file: - # convert uploaded file to temp file in order to upload. - temp_file.write(imageFile.read()) + with NamedTemporaryFile(suffix=f".{suffix}", delete=True) as temp_file: + with open(temp_file.name, 'wb+') as pin_file: + for chunk in imageFile.chunks(): + pin_file.write(chunk) + pin_response = pinata.pin_file_to_ipfs( - temp_file.name, + pin_file.name, '', save_absolute_paths=False ) diff --git a/frontend/src/components/Dashboard/Org/OrgForm.js b/frontend/src/components/Dashboard/Org/OrgForm.js index f9da067..a787f59 100644 --- a/frontend/src/components/Dashboard/Org/OrgForm.js +++ b/frontend/src/components/Dashboard/Org/OrgForm.js @@ -96,10 +96,12 @@ const OrgForm = () => { } } - // Custom image upload. - const onCustomImageUpload = (image) => { - setIsCustomImage(true); - setOrgImage(image); + // Custom image upload. If image gets set to null then get new generative. + const onCustomImageUpload = async (image) => { + setIsCustomImage(image ? true : false); + let customImage = image ? + image : await getPFPImage(firstCharOfName.current); + setOrgImage(image ?? customImage); } // Get a generated image for the org. @@ -117,12 +119,13 @@ const OrgForm = () => { // Pin the org image to IPFS. const pinImage = async (image) => { - const response = await postIPFSImage(image) - if (response.error) { + const response = await postIPFSImage(image); + + if (response?.error) { setError({ - label: 'Could not upload image to IPFS', + label: "Error uploading image to IPFS", message: response.error - }); + }) return; } diff --git a/frontend/src/components/Dashboard/Sidebar/OrgSidebar.js b/frontend/src/components/Dashboard/Sidebar/OrgSidebar.js index 5279803..27e0824 100644 --- a/frontend/src/components/Dashboard/Sidebar/OrgSidebar.js +++ b/frontend/src/components/Dashboard/Sidebar/OrgSidebar.js @@ -64,8 +64,6 @@ const OrgSidebar = ({ address }) => { openConnectModal() }, [openConnectModal, address]) - console.log('ensName', ensName, ensAvatar, ensFetched) - return (
@@ -93,15 +91,21 @@ const OrgSidebar = ({ address }) => { {/* Logged in user header */} {address && !orgId && isAuthenticated && !isWrongNetwork && <> -
- - - {userData?.ens_name ? userData.ens_name : sliceAddress(address)} - -
+ {ensFetched ? +
+ + + {ensName ? ensName : sliceAddress(address)} + +
+ : + + }
Organizations
diff --git a/frontend/src/components/Dashboard/Utils/ImageLoader.js b/frontend/src/components/Dashboard/Utils/ImageLoader.js index 73c5232..836d778 100644 --- a/frontend/src/components/Dashboard/Utils/ImageLoader.js +++ b/frontend/src/components/Dashboard/Utils/ImageLoader.js @@ -4,11 +4,6 @@ import ImageErrorFallback from "@static/images/imgerror.svg"; const ImageLoader = ({className, src, alt}) => { const [ loaded, setLoaded ] = useState(false); - const onLoad = () => { - console.log('loaded') - setLoaded(true); - } - const onError = (e) => { e.onError = null; e.currentTarget.src = ImageErrorFallback; @@ -23,7 +18,7 @@ const ImageLoader = ({className, src, alt}) => { className={className} src={src} alt={alt || ""} - onLoad={onLoad} + onLoad={() => setLoaded(true)} onError={(e) => onError(e)} style={loaded ? {} : { display: 'none' }} />