diff --git a/src/pages/gallery/components/AddCollection.tsx b/src/pages/gallery/components/AddCollection.tsx index 0fd38b63a..37b85fdbe 100644 --- a/src/pages/gallery/components/AddCollection.tsx +++ b/src/pages/gallery/components/AddCollection.tsx @@ -1,4 +1,5 @@ import React, { useState } from "react"; +import { Card } from "react-bootstrap"; import Dropzone from "react-dropzone"; import { DropDiv } from "./CollectionDropZone"; import CreateCollection from "./CreateCollection"; @@ -8,10 +9,9 @@ export default function AddCollection(props) { const [acceptedFiles, setAcceptedFiles] = useState(); const [createCollectionView, setCreateCollectionView] = useState(false); - const { children, closeModal, ...rest } = props; + const { children, closeUploadModal, ...rest } = props; const createCollection = (acceptedFiles) => { - closeModal(); setAcceptedFiles(acceptedFiles); setCreateCollectionView(true); }; @@ -20,7 +20,7 @@ export default function AddCollection(props) { <> @@ -40,14 +40,19 @@ export default function AddCollection(props) { })} > - {children} + + + Create New Album + + ); }} setCreateCollectionView(false)} acceptedFiles={acceptedFiles} /> diff --git a/src/pages/gallery/components/CollectionSelector.tsx b/src/pages/gallery/components/CollectionSelector.tsx index 0447f3a2a..d224e0d37 100644 --- a/src/pages/gallery/components/CollectionSelector.tsx +++ b/src/pages/gallery/components/CollectionSelector.tsx @@ -15,12 +15,10 @@ function CollectionSelector(props) { } = props; const [token, setToken] = useState(null); - const [userMasterKey, setUserMasterKey] = useState(null); useEffect(() => { (async () => { setToken(getData(LS_KEYS.USER).token); - setUserMasterKey(await getActualKey()); })(); }); @@ -56,16 +54,9 @@ function CollectionSelector(props) { - - - Create New Album - - - + /> {CollectionIcons} diff --git a/src/pages/gallery/components/CreateCollection.tsx b/src/pages/gallery/components/CreateCollection.tsx index 560e2187a..0012a40af 100644 --- a/src/pages/gallery/components/CreateCollection.tsx +++ b/src/pages/gallery/components/CreateCollection.tsx @@ -2,32 +2,36 @@ import React, { useState } from 'react'; import { Modal } from 'react-bootstrap'; import { createAlbum } from 'services/collectionService'; import UploadService from 'services/uploadService'; -import { collectionLatestFile, fetchData } from 'services/fileService' +import { collectionLatestFile } from 'services/fileService' +import { getActualKey } from 'utils/common/key'; export default function CreateCollection(props) { - const { masterKey, token, closeModal, acceptedFiles, setData, setProgressView, progressBarProps } = props; + const { token, acceptedFiles, setProgressView, progressBarProps, refetchData, modalView, closeModal, closeUploadModal } = props; const [albumName, setAlbumName] = useState(""); const handleChange = (event) => { setAlbumName(event.target.value); } const handleSubmit = async (event) => { event.preventDefault(); - closeModal(); + closeModal(); + closeUploadModal(); + const masterKey = await getActualKey(); const collection = await createAlbum(albumName, masterKey, token); const collectionLatestFile: collectionLatestFile = { collection, file: null } + progressBarProps.setPercentComplete(0); setProgressView(true); await UploadService.uploadFiles(acceptedFiles, collectionLatestFile, token, progressBarProps); - setData(await fetchData(token, [collectionLatestFile.collection])); + refetchData(); setProgressView(false); } return (