diff --git a/src/components/FullScreenDropZone.tsx b/src/components/FullScreenDropZone.tsx index 391785410..46ff6de8c 100644 --- a/src/components/FullScreenDropZone.tsx +++ b/src/components/FullScreenDropZone.tsx @@ -59,7 +59,7 @@ export default function FullScreenDropZone(props: Props) { useEffect(() => { const handleWatchFolderDrop = (e: DragEvent) => { - if (!appContext.watchModalView) { + if (!appContext.watchFolderView) { return; } @@ -67,7 +67,7 @@ export default function FullScreenDropZone(props: Props) { e.stopPropagation(); const files = e.dataTransfer.files; if (files.length > 0) { - appContext.setWatchModalFiles(files); + appContext.setWatchFolderFiles(files); } }; @@ -75,14 +75,14 @@ export default function FullScreenDropZone(props: Props) { return () => { removeEventListener('drop', handleWatchFolderDrop); }; - }, [appContext.watchModalView]); + }, [appContext.watchFolderView]); return ( - {!appContext.watchModalView ? ( + {!appContext.watchFolderView ? ( ) : null} {isDragActive && ( @@ -90,7 +90,7 @@ export default function FullScreenDropZone(props: Props) { - {appContext.watchModalView + {appContext.watchFolderView ? constants.WATCH_FOLDER_DROPZONE_MESSAGE : constants.UPLOAD_DROPZONE_MESSAGE} diff --git a/src/components/Sidebar/UtilitySection.tsx b/src/components/Sidebar/UtilitySection.tsx index d1eadb44e..696e260ba 100644 --- a/src/components/Sidebar/UtilitySection.tsx +++ b/src/components/Sidebar/UtilitySection.tsx @@ -9,15 +9,15 @@ import { useRouter } from 'next/router'; import { AppContext } from 'pages/_app'; import isElectron from 'is-electron'; import { downloadApp } from 'utils/common'; -import WatchFolderModal from 'components/WatchFolder'; +import WatchFolder from 'components/WatchFolder'; export default function UtilitySection({ closeSidebar }) { const router = useRouter(); const { setDialogMessage, startLoading, - watchModalView, - setWatchModalView, + watchFolderView: watchModalView, + setWatchFolderView: setWatchModalView, } = useContext(AppContext); const [recoverModalView, setRecoveryModalView] = useState(false); @@ -71,7 +71,7 @@ export default function UtilitySection({ closeSidebar }) { close: { variant: 'danger' }, }); - const closeWatchFolderModal = () => setWatchModalView(false); + const closeWatchFolder = () => setWatchModalView(false); return ( <> @@ -108,10 +108,7 @@ export default function UtilitySection({ closeSidebar }) { closeSidebar={closeSidebar} setLoading={startLoading} /> - + {/* { - if ( - appContext.watchServiceIsRunning && - watchService.isUploadRunning() - ) { + if (appContext.isFolderSyncRunning && watchService.isUploadRunning()) { setExpanded(false); } - }, [appContext.watchServiceIsRunning]); + }, [appContext.isFolderSyncRunning]); function confirmCancelUpload() { appContext.setDialogMessage({ diff --git a/src/components/WatchFolder/index.tsx b/src/components/WatchFolder/index.tsx index 591565788..b4ef294b9 100644 --- a/src/components/WatchFolder/index.tsx +++ b/src/components/WatchFolder/index.tsx @@ -14,7 +14,7 @@ interface Iprops { onClose: () => void; } -export default function WatchFolderModal({ open, onClose }: Iprops) { +export default function WatchFolder({ open, onClose }: Iprops) { const [mappings, setMappings] = useState([]); const appContext = useContext(AppContext); @@ -24,12 +24,12 @@ export default function WatchFolderModal({ open, onClose }: Iprops) { useEffect(() => { if ( - appContext.watchModalFiles && - appContext.watchModalFiles.length > 0 + appContext.watchModalFolderFiles && + appContext.watchModalFolderFiles.length > 0 ) { - handleFolderDrop(appContext.watchModalFiles); + handleFolderDrop(appContext.watchModalFolderFiles); } - }, [appContext.watchModalFiles]); + }, [appContext.watchModalFolderFiles]); const handleFolderDrop = async (folders: FileList) => { for (let i = 0; i < folders.length; i++) { diff --git a/src/components/WatchFolder/mappingEntry/entryHeading.tsx b/src/components/WatchFolder/mappingEntry/entryHeading.tsx index fb6347021..5fc7a28b8 100644 --- a/src/components/WatchFolder/mappingEntry/entryHeading.tsx +++ b/src/components/WatchFolder/mappingEntry/entryHeading.tsx @@ -15,7 +15,7 @@ export function EntryHeading({ mapping }) { }}> <> {mapping.collectionName} - {appContext.watchServiceIsRunning && + {appContext.isFolderSyncRunning && watchService.currentEvent?.collectionName === mapping.collectionName && } diff --git a/src/components/WatchFolder/mappingEntry/index.tsx b/src/components/WatchFolder/mappingEntry/index.tsx index f20badd38..7451cdebb 100644 --- a/src/components/WatchFolder/mappingEntry/index.tsx +++ b/src/components/WatchFolder/mappingEntry/index.tsx @@ -19,8 +19,8 @@ export function MappingEntry({ const appContext = React.useContext(AppContext); useEffect(() => { - console.log(appContext.watchServiceIsRunning); - }, [appContext.watchServiceIsRunning]); + console.log(appContext.isFolderSyncRunning); + }, [appContext.isFolderSyncRunning]); const confirmStopWatching = () => { appContext.setDialogMessage({ diff --git a/src/components/pages/gallery/Upload.tsx b/src/components/pages/gallery/Upload.tsx index e511f0dc0..96e166a7b 100644 --- a/src/components/pages/gallery/Upload.tsx +++ b/src/components/pages/gallery/Upload.tsx @@ -132,7 +132,7 @@ export default function Upload(props: Props) { props.setElectronFiles, setCollectionName, props.syncWithRemote, - appContext.setWatchServiceIsRunning + appContext.setIsFolderSyncRunning ); } }, []); diff --git a/src/pages/_app.tsx b/src/pages/_app.tsx index 9d1178e60..f4023ecd3 100644 --- a/src/pages/_app.tsx +++ b/src/pages/_app.tsx @@ -52,12 +52,12 @@ type AppContextType = { finishLoading: () => void; closeMessageDialog: () => void; setDialogMessage: SetDialogBoxAttributes; - watchServiceIsRunning: boolean; - setWatchServiceIsRunning: (isRunning: boolean) => void; - watchModalView: boolean; - setWatchModalView: (isOpen: boolean) => void; - watchModalFiles: FileList; - setWatchModalFiles: (files: FileList) => void; + isFolderSyncRunning: boolean; + setIsFolderSyncRunning: (isRunning: boolean) => void; + watchFolderView: boolean; + setWatchFolderView: (isOpen: boolean) => void; + watchModalFolderFiles: FileList; + setWatchFolderFiles: (files: FileList) => void; }; export enum FLASH_MESSAGE_TYPE { @@ -92,9 +92,9 @@ export default function App({ Component, err }) { const loadingBar = useRef(null); const [dialogMessage, setDialogMessage] = useState(); const [messageDialogView, setMessageDialogView] = useState(false); - const [watchServiceIsRunning, setWatchServiceIsRunning] = useState(false); - const [watchModalView, setWatchModalView] = useState(false); - const [watchModalFiles, setWatchModalFiles] = useState(null); + const [isFolderSyncRunning, setIsFolderSyncRunning] = useState(false); + const [watchFolderView, setWatchFolderView] = useState(false); + const [watchFolderFiles, setWatchFolderFiles] = useState(null); useEffect(() => { if ( @@ -283,12 +283,12 @@ export default function App({ Component, err }) { finishLoading, closeMessageDialog, setDialogMessage, - watchServiceIsRunning, - setWatchServiceIsRunning, - watchModalView, - setWatchModalView, - watchModalFiles, - setWatchModalFiles, + isFolderSyncRunning: isFolderSyncRunning, + setIsFolderSyncRunning: setIsFolderSyncRunning, + watchFolderView: watchFolderView, + setWatchFolderView: setWatchFolderView, + watchModalFolderFiles: watchFolderFiles, + setWatchFolderFiles: setWatchFolderFiles, }}> {loading ? ( diff --git a/src/pages/gallery/index.tsx b/src/pages/gallery/index.tsx index a1292ca24..f2bc7e996 100644 --- a/src/pages/gallery/index.tsx +++ b/src/pages/gallery/index.tsx @@ -280,7 +280,7 @@ export default function Gallery() { ); useEffect(() => { - if (!appContext.watchModalView) { + if (!appContext.watchFolderView) { setDroppedFiles(acceptedFiles); } }, [acceptedFiles]);