rename watchModal to watchFolder

This commit is contained in:
Abhinav 2022-06-19 16:29:41 +05:30
parent 283797dd4a
commit 6b9ed0c622
9 changed files with 37 additions and 43 deletions

View file

@ -59,7 +59,7 @@ export default function FullScreenDropZone(props: Props) {
useEffect(() => { useEffect(() => {
const handleWatchFolderDrop = (e: DragEvent) => { const handleWatchFolderDrop = (e: DragEvent) => {
if (!appContext.watchModalView) { if (!appContext.watchFolderView) {
return; return;
} }
@ -67,7 +67,7 @@ export default function FullScreenDropZone(props: Props) {
e.stopPropagation(); e.stopPropagation();
const files = e.dataTransfer.files; const files = e.dataTransfer.files;
if (files.length > 0) { if (files.length > 0) {
appContext.setWatchModalFiles(files); appContext.setWatchFolderFiles(files);
} }
}; };
@ -75,14 +75,14 @@ export default function FullScreenDropZone(props: Props) {
return () => { return () => {
removeEventListener('drop', handleWatchFolderDrop); removeEventListener('drop', handleWatchFolderDrop);
}; };
}, [appContext.watchModalView]); }, [appContext.watchFolderView]);
return ( return (
<DropDiv <DropDiv
{...props.getRootProps({ {...props.getRootProps({
onDragEnter, onDragEnter,
})}> })}>
{!appContext.watchModalView ? ( {!appContext.watchFolderView ? (
<input {...props.getInputProps()} /> <input {...props.getInputProps()} />
) : null} ) : null}
{isDragActive && ( {isDragActive && (
@ -90,7 +90,7 @@ export default function FullScreenDropZone(props: Props) {
<CloseButtonWrapper onClick={onDragLeave}> <CloseButtonWrapper onClick={onDragLeave}>
<CloseIcon /> <CloseIcon />
</CloseButtonWrapper> </CloseButtonWrapper>
{appContext.watchModalView {appContext.watchFolderView
? constants.WATCH_FOLDER_DROPZONE_MESSAGE ? constants.WATCH_FOLDER_DROPZONE_MESSAGE
: constants.UPLOAD_DROPZONE_MESSAGE} : constants.UPLOAD_DROPZONE_MESSAGE}
</Overlay> </Overlay>

View file

@ -9,15 +9,15 @@ import { useRouter } from 'next/router';
import { AppContext } from 'pages/_app'; import { AppContext } from 'pages/_app';
import isElectron from 'is-electron'; import isElectron from 'is-electron';
import { downloadApp } from 'utils/common'; import { downloadApp } from 'utils/common';
import WatchFolderModal from 'components/WatchFolder'; import WatchFolder from 'components/WatchFolder';
export default function UtilitySection({ closeSidebar }) { export default function UtilitySection({ closeSidebar }) {
const router = useRouter(); const router = useRouter();
const { const {
setDialogMessage, setDialogMessage,
startLoading, startLoading,
watchModalView, watchFolderView: watchModalView,
setWatchModalView, setWatchFolderView: setWatchModalView,
} = useContext(AppContext); } = useContext(AppContext);
const [recoverModalView, setRecoveryModalView] = useState(false); const [recoverModalView, setRecoveryModalView] = useState(false);
@ -71,7 +71,7 @@ export default function UtilitySection({ closeSidebar }) {
close: { variant: 'danger' }, close: { variant: 'danger' },
}); });
const closeWatchFolderModal = () => setWatchModalView(false); const closeWatchFolder = () => setWatchModalView(false);
return ( return (
<> <>
<SidebarButton onClick={openRecoveryKeyModal}> <SidebarButton onClick={openRecoveryKeyModal}>
@ -108,10 +108,7 @@ export default function UtilitySection({ closeSidebar }) {
closeSidebar={closeSidebar} closeSidebar={closeSidebar}
setLoading={startLoading} setLoading={startLoading}
/> />
<WatchFolderModal <WatchFolder open={watchModalView} onClose={closeWatchFolder} />
open={watchModalView}
onClose={closeWatchFolderModal}
/>
{/* <FixLargeThumbnails {/* <FixLargeThumbnails
isOpen={fixLargeThumbsView} isOpen={fixLargeThumbsView}

View file

@ -45,13 +45,10 @@ export default function UploadProgress({
const [expanded, setExpanded] = useState(true); const [expanded, setExpanded] = useState(true);
useEffect(() => { useEffect(() => {
if ( if (appContext.isFolderSyncRunning && watchService.isUploadRunning()) {
appContext.watchServiceIsRunning &&
watchService.isUploadRunning()
) {
setExpanded(false); setExpanded(false);
} }
}, [appContext.watchServiceIsRunning]); }, [appContext.isFolderSyncRunning]);
function confirmCancelUpload() { function confirmCancelUpload() {
appContext.setDialogMessage({ appContext.setDialogMessage({

View file

@ -14,7 +14,7 @@ interface Iprops {
onClose: () => void; onClose: () => void;
} }
export default function WatchFolderModal({ open, onClose }: Iprops) { export default function WatchFolder({ open, onClose }: Iprops) {
const [mappings, setMappings] = useState<WatchMapping[]>([]); const [mappings, setMappings] = useState<WatchMapping[]>([]);
const appContext = useContext(AppContext); const appContext = useContext(AppContext);
@ -24,12 +24,12 @@ export default function WatchFolderModal({ open, onClose }: Iprops) {
useEffect(() => { useEffect(() => {
if ( if (
appContext.watchModalFiles && appContext.watchModalFolderFiles &&
appContext.watchModalFiles.length > 0 appContext.watchModalFolderFiles.length > 0
) { ) {
handleFolderDrop(appContext.watchModalFiles); handleFolderDrop(appContext.watchModalFolderFiles);
} }
}, [appContext.watchModalFiles]); }, [appContext.watchModalFolderFiles]);
const handleFolderDrop = async (folders: FileList) => { const handleFolderDrop = async (folders: FileList) => {
for (let i = 0; i < folders.length; i++) { for (let i = 0; i < folders.length; i++) {

View file

@ -15,7 +15,7 @@ export function EntryHeading({ mapping }) {
}}> }}>
<> <>
{mapping.collectionName} {mapping.collectionName}
{appContext.watchServiceIsRunning && {appContext.isFolderSyncRunning &&
watchService.currentEvent?.collectionName === watchService.currentEvent?.collectionName ===
mapping.collectionName && <SyncProgressIcon />} mapping.collectionName && <SyncProgressIcon />}
</> </>

View file

@ -19,8 +19,8 @@ export function MappingEntry({
const appContext = React.useContext(AppContext); const appContext = React.useContext(AppContext);
useEffect(() => { useEffect(() => {
console.log(appContext.watchServiceIsRunning); console.log(appContext.isFolderSyncRunning);
}, [appContext.watchServiceIsRunning]); }, [appContext.isFolderSyncRunning]);
const confirmStopWatching = () => { const confirmStopWatching = () => {
appContext.setDialogMessage({ appContext.setDialogMessage({

View file

@ -132,7 +132,7 @@ export default function Upload(props: Props) {
props.setElectronFiles, props.setElectronFiles,
setCollectionName, setCollectionName,
props.syncWithRemote, props.syncWithRemote,
appContext.setWatchServiceIsRunning appContext.setIsFolderSyncRunning
); );
} }
}, []); }, []);

View file

@ -52,12 +52,12 @@ type AppContextType = {
finishLoading: () => void; finishLoading: () => void;
closeMessageDialog: () => void; closeMessageDialog: () => void;
setDialogMessage: SetDialogBoxAttributes; setDialogMessage: SetDialogBoxAttributes;
watchServiceIsRunning: boolean; isFolderSyncRunning: boolean;
setWatchServiceIsRunning: (isRunning: boolean) => void; setIsFolderSyncRunning: (isRunning: boolean) => void;
watchModalView: boolean; watchFolderView: boolean;
setWatchModalView: (isOpen: boolean) => void; setWatchFolderView: (isOpen: boolean) => void;
watchModalFiles: FileList; watchModalFolderFiles: FileList;
setWatchModalFiles: (files: FileList) => void; setWatchFolderFiles: (files: FileList) => void;
}; };
export enum FLASH_MESSAGE_TYPE { export enum FLASH_MESSAGE_TYPE {
@ -92,9 +92,9 @@ export default function App({ Component, err }) {
const loadingBar = useRef(null); const loadingBar = useRef(null);
const [dialogMessage, setDialogMessage] = useState<DialogBoxAttributes>(); const [dialogMessage, setDialogMessage] = useState<DialogBoxAttributes>();
const [messageDialogView, setMessageDialogView] = useState(false); const [messageDialogView, setMessageDialogView] = useState(false);
const [watchServiceIsRunning, setWatchServiceIsRunning] = useState(false); const [isFolderSyncRunning, setIsFolderSyncRunning] = useState(false);
const [watchModalView, setWatchModalView] = useState(false); const [watchFolderView, setWatchFolderView] = useState(false);
const [watchModalFiles, setWatchModalFiles] = useState<FileList>(null); const [watchFolderFiles, setWatchFolderFiles] = useState<FileList>(null);
useEffect(() => { useEffect(() => {
if ( if (
@ -283,12 +283,12 @@ export default function App({ Component, err }) {
finishLoading, finishLoading,
closeMessageDialog, closeMessageDialog,
setDialogMessage, setDialogMessage,
watchServiceIsRunning, isFolderSyncRunning: isFolderSyncRunning,
setWatchServiceIsRunning, setIsFolderSyncRunning: setIsFolderSyncRunning,
watchModalView, watchFolderView: watchFolderView,
setWatchModalView, setWatchFolderView: setWatchFolderView,
watchModalFiles, watchModalFolderFiles: watchFolderFiles,
setWatchModalFiles, setWatchFolderFiles: setWatchFolderFiles,
}}> }}>
{loading ? ( {loading ? (
<VerticallyCentered> <VerticallyCentered>

View file

@ -280,7 +280,7 @@ export default function Gallery() {
); );
useEffect(() => { useEffect(() => {
if (!appContext.watchModalView) { if (!appContext.watchFolderView) {
setDroppedFiles(acceptedFiles); setDroppedFiles(acceptedFiles);
} }
}, [acceptedFiles]); }, [acceptedFiles]);