TagSpaces is an offline, open source, document manager with tagging support
clean mainPage dialogs (#2118)
Stanimir66555a6f624d
diff --git a/package-lock.json b/package-lock.jsonindex bfe6259c0..c58e7affe 100644--- a/package-lock.json+++ b/package-lock.json@@ -196,7 +196,7 @@"yarn": "please-use-npm"},"optionalDependencies": {- "@tagspacespro/tagspacespro": "5.0.51"+ "@tagspacespro/tagspacespro": "5.0.51-alpha.3"}},"node_modules/@adobe/css-tools": {@@ -13873,9 +13873,9 @@}},"node_modules/@tagspacespro/tagspacespro": {- "version": "5.0.51",- "resolved": "https://npm.pkg.github.com/download/@tagspacespro/tagspacespro/5.0.51/a5c895ca00a87597e3756d325ba3d464329baaca",- "integrity": "sha512-QJVwSGcZi9EWB4Wt9g2elAxVcbzevPSWtbdPWrPus8qzy9Kavd/t+x+MJOmOZcYe8NexSctTvgKU5a2Qfw6dGA==",+ "version": "5.0.51-alpha.3",+ "resolved": "https://npm.pkg.github.com/download/@tagspacespro/tagspacespro/5.0.51-alpha.3/56f0ab8d8942e3f6338e5e45640e953de21b260a",+ "integrity": "sha512-CvZ26KsYu8i24m59BO8yJ5d129IpMlXJ31JwxBIyJOGJoWijPb63pzatoCpdfVRYU11PTHDJ8mqQ50mTmADfUw==","license": "Proprietary","optional": true},diff --git a/package.json b/package.jsonindex f43f0af82..fa9c16947 100644--- a/package.json+++ b/package.json@@ -229,7 +229,7 @@"uuid": "^9.0.0"},"optionalDependencies": {- "@tagspacespro/tagspacespro": "5.0.51"+ "@tagspacespro/tagspacespro": "5.0.51-alpha.3"},"devDependencies": {"@electron/notarize": "^2.3.2",diff --git a/src/renderer/components/CustomLogo.tsx b/src/renderer/components/CustomLogo.tsxindex 69cab51a6..53097f35a 100644--- a/src/renderer/components/CustomLogo.tsx+++ b/src/renderer/components/CustomLogo.tsx@@ -29,10 +29,11 @@ import versionMeta from '../version.json';import { actions, isUpdateAvailable } from '-/reducers/app';import { useTranslation } from 'react-i18next';import { Badge, Typography } from '@mui/material';+import { useAboutDialogContext } from '-/components/dialogs/hooks/useAboutDialogContext';function CustomLogo() {const { t } = useTranslation();- const dispatch = useDispatch();+ const { openAboutDialog } = useAboutDialogContext();const updateAvailable = useSelector(isUpdateAvailable);const tsType = Pro ? 'PRO' : 'LITE';@@ -49,7 +50,7 @@ function CustomLogo() {return (<div- onClick={() => dispatch(actions.toggleAboutDialog())}+ onClick={() => openAboutDialog()}style={{width: '100%',textAlign: 'center',diff --git a/src/renderer/components/DirectoryListView.tsx b/src/renderer/components/DirectoryListView.tsxindex 76512b3e4..e1da8714f 100644--- a/src/renderer/components/DirectoryListView.tsx+++ b/src/renderer/components/DirectoryListView.tsx@@ -1,5 +1,5 @@import React, { useRef, useState, useEffect } from 'react';-import { useDispatch, useSelector } from 'react-redux';+import { useSelector } from 'react-redux';import Button from '@mui/material/Button';import Select from '@mui/material/Select';import MenuItem from '@mui/material/MenuItem';@@ -13,7 +13,6 @@ import { extractContainingDirectoryPath } from '@tagspaces/tagspaces-common/pathimport { getShowUnixHiddenEntries } from '-/reducers/settings';import AppConfig from '-/AppConfig';import { TS } from '-/tagspaces.namespace';-import { actions as AppActions, AppDispatch } from '-/reducers/app';import {ParentFolderIcon,NewFolderIcon,@@ -23,6 +22,7 @@ import { useTranslation } from 'react-i18next';import { useCurrentLocationContext } from '-/hooks/useCurrentLocationContext';import Typography from '@mui/material/Typography';import { CommonLocation } from '-/utils/CommonLocation';+import { useCreateDirectoryDialogContext } from '-/components/dialogs/hooks/useCreateDirectoryDialogContext';interface Props {setTargetDir: (dirPath: string) => void;@@ -33,6 +33,7 @@ function DirectoryListView(props: Props) {const { t } = useTranslation();const { currentLocation, findLocation, locations } =useCurrentLocationContext();+ const { openCreateDirectoryDialog } = useCreateDirectoryDialogContext();// const locations: Array<CommonLocation> = useSelector(getLocations);const showUnixHiddenEntries: boolean = useSelector(getShowUnixHiddenEntries);const chosenLocationId = useRef<string>(@@ -56,8 +57,6 @@ function DirectoryListView(props: Props) {}}, [chosenLocationId.current]);- const dispatch: AppDispatch = useDispatch();-const handleLocationChange = (event: React.ChangeEvent<HTMLInputElement>) => {chosenLocationId.current = event.target.value;const chosenLocation = findLocation(chosenLocationId.current);@@ -184,18 +183,11 @@ function DirectoryListView(props: Props) {style={{ margin: 5 }}data-tid="newSubdirectoryTID"onClick={() => {- //stopWatching();- dispatch(- AppActions.toggleCreateDirectoryDialog({- rootDirPath: chosenDirectory.current,- callback: (newDirPath) => {- listDirectory(chosenDirectory.current);- setTargetDir(newDirPath);- //watchForChanges();- },- reflect: false,- }),- );+ openCreateDirectoryDialog(chosenDirectory.current, (newDirPath) => {+ listDirectory(chosenDirectory.current);+ setTargetDir(newDirPath);+ });+ //reflect: false,}}>{t('core:newSubdirectory')}diff --git a/src/renderer/components/EditDescription.tsx b/src/renderer/components/EditDescription.tsxindex 3fa972418..2020da076 100644--- a/src/renderer/components/EditDescription.tsx+++ b/src/renderer/components/EditDescription.tsx@@ -3,7 +3,7 @@ import { styled, useTheme } from '@mui/material/styles';import Typography from '@mui/material/Typography';import { MilkdownEditor, MilkdownRef } from '@tagspaces/tagspaces-md';import { useTranslation } from 'react-i18next';-import { useDescriptionContext } from '-/hooks/useDescriptionContext';+import { useFilePropertiesContext } from '-/hooks/useFilePropertiesContext';import EditDescriptionButtons from '-/components/EditDescriptionButtons';import { useDirectoryContentContext } from '-/hooks/useDirectoryContentContext';import { Pro } from '-/pro';@@ -30,7 +30,7 @@ function EditDescription() {// const { openedEntry } = useOpenedEntryContext();const { currentDirectoryPath } = useDirectoryContentContext();const { description, setDescription, isEditMode, setEditMode } =- useDescriptionContext();+ useFilePropertiesContext();const fileDescriptionRef = useRef<MilkdownRef>(null);//const [editMode, setEditMode] = useState<boolean>(false);diff --git a/src/renderer/components/EditDescriptionButtons.tsx b/src/renderer/components/EditDescriptionButtons.tsxindex ba97815f6..f1dfeebd1 100644--- a/src/renderer/components/EditDescriptionButtons.tsx+++ b/src/renderer/components/EditDescriptionButtons.tsx@@ -4,7 +4,7 @@ import Button from '@mui/material/Button';import { ProTooltip } from '-/components/HelperComponents';import { Pro } from '-/pro';import { useTranslation } from 'react-i18next';-import { useDescriptionContext } from '-/hooks/useDescriptionContext';+import { useFilePropertiesContext } from '-/hooks/useFilePropertiesContext';import ConfirmDialog from '-/components/dialogs/ConfirmDialog';export interface DescriptionChangedRef {@@ -23,7 +23,7 @@ const EditDescriptionButtons: React.FC<Props> = ({ buttonsRef }) => {saveDescription,isEditMode,setEditMode,- } = useDescriptionContext();+ } = useFilePropertiesContext();const [isDescriptionChanged, descriptionChanged] = useState<boolean>(false);React.useImperativeHandle(buttonsRef, () => ({diff --git a/src/renderer/components/EntryContainer.tsx b/src/renderer/components/EntryContainer.tsxindex 795d9ae3f..5299e6ea9 100644--- a/src/renderer/components/EntryContainer.tsx+++ b/src/renderer/components/EntryContainer.tsx@@ -19,7 +19,6 @@import React, {MutableRefObject,useCallback,- useContext,useEffect,useReducer,useRef,@@ -60,23 +59,21 @@ import EntryContainerTabs from '-/components/EntryContainerTabs';import EntryContainerNav from '-/components/EntryContainerNav';import EntryContainerTitle from '-/components/EntryContainerTitle';import { useTranslation } from 'react-i18next';-import { useDescriptionContext } from '-/hooks/useDescriptionContext';+import { useFilePropertiesContext } from '-/hooks/useFilePropertiesContext';import { useOpenedEntryContext } from '-/hooks/useOpenedEntryContext';import { useDirectoryContentContext } from '-/hooks/useDirectoryContentContext';import { useCurrentLocationContext } from '-/hooks/useCurrentLocationContext';import { useNotificationContext } from '-/hooks/useNotificationContext';-import { getRelativeEntryPath } from '-/services/utils-io';import { usePlatformFacadeContext } from '-/hooks/usePlatformFacadeContext';import { SaveIcon, EditIcon } from '-/components/CommonIcons';import { useIOActionsContext } from '-/hooks/useIOActionsContext';import { usePerspectiveActionsContext } from '-/hooks/usePerspectiveActionsContext';import { useEditedEntryContext } from '-/hooks/useEditedEntryContext';-const historyKeys = Pro ? Pro.keys.historyKeys : {};+//const historyKeys = Pro ? Pro.keys.historyKeys : {};function EntryContainer() {const { t } = useTranslation();- // const dispatch: AppDispatch = useDispatch();const {openedEntry,closeAllFiles,@@ -84,15 +81,16 @@ function EntryContainer() {toggleEntryFullWidth,isEntryInFullWidth,reflectUpdateOpenedFileContent,- addToEntryContainer,+ fileChanged,+ setFileChanged,} = useOpenedEntryContext();const { setReflectActions } = useEditedEntryContext();const { setActions } = usePerspectiveActionsContext();- const { saveDescription, description } = useDescriptionContext();+ const { saveDescription, description, isEditMode, setEditMode } =+ useFilePropertiesContext();const { setAutoSave, getMetadataID } = useIOActionsContext();const { findLocation, readOnlyMode } = useCurrentLocationContext();- const { openDirectory, currentDirectoryPath, currentLocationPath } =- useDirectoryContentContext();+ const { openDirectory, currentDirectoryPath } = useDirectoryContentContext();const { copyFilePromiseOverwrite, copyFilePromise, saveTextFilePromise } =usePlatformFacadeContext();const { showNotification } = useNotificationContext();@@ -133,7 +131,6 @@ function EntryContainer() {useRef<HTMLIFrameElement>(null);const fileViewerContainer: MutableRefObject<HTMLDivElement> =useRef<HTMLDivElement>(null);- const fileChanged = useRef<boolean>(false);const eventID = useRef<string>(getUuid());const cLocation = findLocation(openedEntry.locationID);@@ -221,9 +218,9 @@ function EntryContainer() {useEffect(() => {if (openedEntry && openedEntry.meta && openedEntry.meta.autoSave) {- if (fileChanged.current) {+ if (fileChanged) {timer.current = setInterval(() => {- if (openedEntry.meta.autoSave && fileChanged.current) {+ if (openedEntry.meta.autoSave && fileChanged) {startSavingFile();console.debug('autosave');}@@ -239,7 +236,7 @@ function EntryContainer() {clearInterval(timer.current);}};- }, [openedEntry, fileChanged.current]);+ }, [openedEntry, fileChanged]);// editor is not loaded in this time - change theme after loadDefaultTextContentuseEffect(() => {@@ -362,7 +359,7 @@ function EntryContainer() {fileViewer.current.contentWindow.setContent(content,fileDirectory,- !openedEntry.editMode,+ !isEditMode,theme.palette.mode,);}@@ -373,12 +370,7 @@ function EntryContainer() {});break;case 'contentChangedInEditor': {- if (!fileChanged.current) {- fileChanged.current = true;- openedEntry.editMode = true;- // to render DOT before file name (only first time)- forceUpdate();- }+ setFileChanged(true);break;}default:@@ -391,10 +383,11 @@ function EntryContainer() {const reloadDocument = () => {if (openedEntry) {- if (openedEntry.editMode && fileChanged.current) {+ if (isEditMode && fileChanged) {// openedEntry.changed) {setSaveBeforeReloadConfirmDialogOpened(true);} else {+ setEditMode(false);reloadOpenedFile();}}@@ -405,7 +398,7 @@ function EntryContainer() {event.preventDefault(); // Let's stop this event.event.stopPropagation();}- if (openedEntry && fileChanged.current && openedEntry.editMode) {+ if (openedEntry && fileChanged && isEditMode) {// openedEntry.changedsetSaveBeforeCloseConfirmDialogOpened(true);} else {@@ -419,7 +412,7 @@ function EntryContainer() {};const startSavingFile = () => {- if (openedEntry.editMode) {+ if (isEditMode) {savingFile();} else {saveDescription();@@ -436,11 +429,11 @@ function EntryContainer() {) {try {//check if file is changed- if (fileChanged.current || force) {+ if (fileChanged || force) {setSavingInProgress(true);save(openedEntry).then((success) => {if (success) {- fileChanged.current = false;+ setFileChanged(false);// showNotification(// t('core:fileSavedSuccessfully'),// NotificationTypes.default@@ -561,15 +554,8 @@ function EntryContainer() {}const editOpenedFile = () => {- addToEntryContainer({ ...openedEntry, editMode: true });- /* switchLocationTypeByID(openedEntry.locationId).then(() => {- updateOpenedFile(openedEntry.path, {- id: '',- ...openedEntry,- editMode: true,- shouldReload: undefined,- }).then(() => switchCurrentLocationType());- });*/+ // addToEntryContainer(openedEntry);+ setEditMode(true);};/*const setPercent = (p: number | undefined) => {@@ -672,28 +658,24 @@ function EntryContainer() {let closeCancelIcon;if (desktopMode) {- closeCancelIcon = fileChanged.current ? (- <CancelIcon />- ) : (- <CloseEditIcon />- );+ closeCancelIcon = fileChanged ? <CancelIcon /> : <CloseEditIcon />;}let editFile = null;if (editingSupported) {- if (openedEntry.editMode) {+ if (isEditMode) {editFile = (<ButtonGroup><Tooltip title={t('core:cancelEditing')}><Button- onClick={reloadDocument}+ onClick={() => setEditMode(false) /*reloadDocument*/}aria-label={t('core:cancelEditing')}size="small"variant="outlined"color="primary"startIcon={closeCancelIcon}>- {fileChanged.current ? t('core:cancel') : t('core:closeButton')}+ {fileChanged ? t('core:cancel') : t('core:closeButton')}</Button></Tooltip><Tooltip@@ -840,7 +822,6 @@ function EntryContainer() {}}><EntryContainerTitle- isFileChanged={fileChanged.current}reloadDocument={reloadDocument}toggleFullScreen={toggleFullScreen}startClosingEntry={startClosingEntry}@@ -884,7 +865,6 @@ function EntryContainer() {fileViewerContainer={fileViewerContainer}toggleFullScreen={toggleFullScreen}eventID={eventID.current}- isFileChanged={fileChanged.current}height={tabIndex !== undefined ? '100%' : 'calc(100% - 100px)'}/>)}@@ -924,14 +904,7 @@ function EntryContainer() {startSavingFile();} else {setSaveBeforeReloadConfirmDialogOpened(false);- /*updateOpenedFile(openedEntry.path, {- id: '',- ...openedEntry,- editMode: false,- // changed: false,- shouldReload: true,- });*/- fileChanged.current = false;+ setFileChanged(false);}}}cancelDialogTID="cancelSaveBeforeCloseDialog"diff --git a/src/renderer/components/EntryContainerTitle.tsx b/src/renderer/components/EntryContainerTitle.tsxindex a26fab351..41ae993d0 100644--- a/src/renderer/components/EntryContainerTitle.tsx+++ b/src/renderer/components/EntryContainerTitle.tsx@@ -54,7 +54,6 @@ const FileBadge = styled('span')(({ theme }) => ({}));interface Props {- isFileChanged: boolean;toggleFullScreen: () => void;reloadDocument: () => void;startClosingEntry: (event) => void;@@ -64,7 +63,6 @@ interface Props {function EntryContainerTitle(props: Props) {const {- isFileChanged,reloadDocument,toggleFullScreen,startClosingEntry,@@ -73,7 +71,7 @@ function EntryContainerTitle(props: Props) {} = props;const { t } = useTranslation();const theme = useTheme();- const { openedEntry, sharingLink } = useOpenedEntryContext();+ const { openedEntry, sharingLink, fileChanged } = useOpenedEntryContext();const { findLocation } = useCurrentLocationContext();const { showNotification } = useNotificationContext();//const locations = useSelector(getLocations);@@ -149,7 +147,7 @@ function EntryContainerTitle(props: Props) {>{openedEntry.isFile ? (<>- {isFileChanged ? (+ {fileChanged ? (<Tooltip title={t('core:fileChanged')}><spanstyle={{diff --git a/src/renderer/components/EntryProperties.tsx b/src/renderer/components/EntryProperties.tsxindex b4c3a621d..8876b5e0d 100644--- a/src/renderer/components/EntryProperties.tsx+++ b/src/renderer/components/EntryProperties.tsx@@ -98,6 +98,7 @@ import { useIOActionsContext } from '-/hooks/useIOActionsContext';import { useCurrentLocationContext } from '-/hooks/useCurrentLocationContext';import { useNotificationContext } from '-/hooks/useNotificationContext';import { generateClipboardLink } from '-/utils/dom';+import { useFilePropertiesContext } from '-/hooks/useFilePropertiesContext';const PREFIX = 'EntryProperties';@@ -225,6 +226,7 @@ function EntryProperties(props: Props) {const theme = useTheme();const { openedEntry, sharingLink, getOpenedDirProps } =useOpenedEntryContext();+ const { isEditMode } = useFilePropertiesContext();const {renameDirectory,renameFile,@@ -339,7 +341,7 @@ function EntryProperties(props: Props) {showNotification(t('core:thisFunctionalityIsAvailableInPro'));return true;}- if (!openedEntry.editMode && editName === undefined) {+ if (!isEditMode && editName === undefined) {setFileThumbChooseDialogOpened(!isFileThumbChooseDialogOpened);}};@@ -349,7 +351,7 @@ function EntryProperties(props: Props) {showNotification(t('core:thisFunctionalityIsAvailableInPro'));return true;}- if (!openedEntry.editMode && editName === undefined) {+ if (!isEditMode && editName === undefined) {setBgndImgChooseDialogOpened(!isBgndImgChooseDialogOpened);}};@@ -521,7 +523,7 @@ function EntryProperties(props: Props) {readOnly: editName === undefined,endAdornment: (<InputAdornment position="end">- {!readOnlyMode && !openedEntry.editMode && (+ {!readOnlyMode && !isEditMode && (<div style={{ textAlign: 'right' }}>{editName !== undefined ? (<div>@@ -561,7 +563,7 @@ function EntryProperties(props: Props) {defaultValue={entryName} // openedEntry.current.name}inputRef={fileNameRef}onClick={() => {- if (!openedEntry.editMode && editName === undefined) {+ if (!isEditMode && editName === undefined) {activateEditNameField();}}}@@ -776,17 +778,15 @@ function EntryProperties(props: Props) {),endAdornment: (<InputAdornment position="end">- {!readOnlyMode &&- !openedEntry.editMode &&- editName === undefined && (- <Button- data-tid="moveCopyEntryTID"- color="primary"- onClick={toggleMoveCopyFilesDialog}- >- {t('core:move')}- </Button>- )}+ {!readOnlyMode && !isEditMode && editName === undefined && (+ <Button+ data-tid="moveCopyEntryTID"+ color="primary"+ onClick={toggleMoveCopyFilesDialog}+ >+ {t('core:move')}+ </Button>+ )}</InputAdornment>),}}@@ -1034,7 +1034,7 @@ function EntryProperties(props: Props) {style={{ alignItems: 'center' }}>{!readOnlyMode &&- !openedEntry.editMode &&+ !isEditMode &&editName === undefined && (<ProTooltip tooltip={t('changeThumbnail')}><Button@@ -1085,7 +1085,7 @@ function EntryProperties(props: Props) {style={{ alignItems: 'center' }}>{!readOnlyMode &&- !openedEntry.editMode &&+ !isEditMode &&editName === undefined && (<ProTooltip tooltip={t('changeBackgroundImage')}><Buttondiff --git a/src/renderer/components/FileView.tsx b/src/renderer/components/FileView.tsxindex e9d6c1985..3025c936a 100644--- a/src/renderer/components/FileView.tsx+++ b/src/renderer/components/FileView.tsx@@ -16,17 +16,19 @@**/-import React, { MutableRefObject, useEffect, useRef } from 'react';+import React, { MutableRefObject, useEffect } from 'react';import { rgbToHex, useTheme } from '@mui/material/styles';import CloseIcon from '@mui/icons-material/Close';import useEventListener from '-/utils/useEventListener';import { useTranslation } from 'react-i18next';import { useDirectoryContentContext } from '-/hooks/useDirectoryContentContext';import { useOpenedEntryContext } from '-/hooks/useOpenedEntryContext';+import { useFilePropertiesContext } from '-/hooks/useFilePropertiesContext';+import AppConfig from '-/AppConfig';+import { actions as SettingsActions } from '-/reducers/settings';interface Props {isFullscreen?: boolean;- isFileChanged: boolean;fileViewer: MutableRefObject<HTMLIFrameElement>;fileViewerContainer: MutableRefObject<HTMLDivElement>;toggleFullScreen?: () => void;@@ -38,37 +40,40 @@ function FileView(props: Props) {const { i18n } = useTranslation();const theme = useTheme();const { openedEntry } = useOpenedEntryContext();+ const { isEditMode } = useFilePropertiesContext();const {fileViewer,isFullscreen,- isFileChanged,fileViewerContainer,toggleFullScreen,height,eventID,} = props;- const { searchQuery, isSearchMode } = useDirectoryContentContext();- const fileOpenerURL = useRef<string>(getFileOpenerURL());+ const { searchQuery } = useDirectoryContentContext();useEffect(() => {- if (!isFileChanged) {- fileOpenerURL.current = getFileOpenerURL();- }- }, [openedEntry, isFileChanged, isSearchMode]);+ if (AppConfig.isElectron) {+ window.electronIO.ipcRenderer.on('play-pause', (arg) => {+ if (+ fileViewer &&+ fileViewer.current &&+ fileViewer.current.contentWindow &&+ // @ts-ignore+ fileViewer.current.contentWindow.togglePlay+ ) {+ // @ts-ignore+ fileViewer.current.contentWindow.togglePlay();+ }+ });- useEventListener('toggle-resume', () => {- if (- fileViewer &&- fileViewer.current &&- fileViewer.current.contentWindow &&- // @ts-ignore- fileViewer.current.contentWindow.togglePlay- ) {- // @ts-ignore- fileViewer.current.contentWindow.togglePlay();+ return () => {+ if (window.electronIO.ipcRenderer) {+ window.electronIO.ipcRenderer.removeAllListeners('play-pause');+ }+ };}- });+ }, []);function getFileOpenerURL(): string {if (openedEntry && openedEntry.path) {@@ -108,7 +113,7 @@ function FileView(props: Props) {extTextColor +extBgndColor;- if (openedEntry.editMode && openedEntry.editingExtensionPath) {+ if (isEditMode && openedEntry.editingExtensionPath) {return (openedEntry.editingExtensionPath +'/index.html?file=' +@@ -180,7 +185,7 @@ function FileView(props: Props) {border: 0,}}allow="clipboard-write *"- src={fileOpenerURL.current}+ src={getFileOpenerURL() /*fileOpenerURL.current*/}allowFullScreensandbox="allow-same-origin allow-scripts allow-modals allow-downloads"id={'FileViewer' + eventID}diff --git a/src/renderer/components/FolderContainer.tsx b/src/renderer/components/FolderContainer.tsxindex 0ce066798..4b165bd2e 100644--- a/src/renderer/components/FolderContainer.tsx+++ b/src/renderer/components/FolderContainer.tsx@@ -50,22 +50,22 @@ import { useDirectoryContentContext } from '-/hooks/useDirectoryContentContext';import RenderPerspective from '-/components/RenderPerspective';import { adjustKeyBinding } from '-/components/dialogs/KeyboardDialog';import { useFileUploadDialogContext } from '-/components/dialogs/hooks/useFileUploadDialogContext';+import { useProTeaserDialogContext } from '-/components/dialogs/hooks/useProTeaserDialogContext';interface Props {toggleDrawer?: () => void;- toggleProTeaser: (slidePage?: string) => void;drawerOpened: boolean;goBack: () => void;goForward: () => void;}function FolderContainer(props: Props) {- const { toggleDrawer, toggleProTeaser, goBack, goForward, drawerOpened } =- props;+ const { toggleDrawer, goBack, goForward, drawerOpened } = props;const { t } = useTranslation();const theme = useTheme();const { openFileUploadDialog } = useFileUploadDialogContext();+ const { openProTeaserDialog } = useProTeaserDialogContext();const {setSearchQuery,currentDirectoryEntries,@@ -142,13 +142,13 @@ function FolderContainer(props: Props) {) {setManualDirectoryPerspective(perspectiveId);} else if (perspectiveId === PerspectiveIDs.GALLERY) {- toggleProTeaser(PerspectiveIDs.GALLERY);+ openProTeaserDialog(PerspectiveIDs.GALLERY);} else if (perspectiveId === PerspectiveIDs.MAPIQUE) {- toggleProTeaser(PerspectiveIDs.MAPIQUE);+ openProTeaserDialog(PerspectiveIDs.MAPIQUE);} else if (perspectiveId === PerspectiveIDs.KANBAN) {- toggleProTeaser(PerspectiveIDs.KANBAN);+ openProTeaserDialog(PerspectiveIDs.KANBAN);} else if (perspectiveId === PerspectiveIDs.FOLDERVIZ) {- toggleProTeaser(PerspectiveIDs.FOLDERVIZ);+ openProTeaserDialog(PerspectiveIDs.FOLDERVIZ);}};diff --git a/src/renderer/components/HelpFeedbackPanel.tsx b/src/renderer/components/HelpFeedbackPanel.tsxindex 68cc70ba8..9151f8a56 100644--- a/src/renderer/components/HelpFeedbackPanel.tsx+++ b/src/renderer/components/HelpFeedbackPanel.tsx@@ -43,12 +43,12 @@ import { openURLExternally } from '-/services/utils-io';import { classes, SidePanel } from '-/components/SidePanels.css';import { useTheme } from '@mui/material/styles';import { useTranslation } from 'react-i18next';+import { useAboutDialogContext } from '-/components/dialogs/hooks/useAboutDialogContext';+import { useOnboardingDialogContext } from '-/components/dialogs/hooks/useOnboardingDialogContext';+import { useKeyboardDialogContext } from '-/components/dialogs/hooks/useKeyboardDialogContext';+import { useProTeaserDialogContext } from '-/components/dialogs/hooks/useProTeaserDialogContext';interface Props {- toggleAboutDialog?: () => void;- toggleKeysDialog: () => void;- toggleOnboardingDialog: () => void;- toggleProTeaser: (slidePage?: string) => void;style?: any;reduceHeightBy?: number;}@@ -56,13 +56,11 @@ interface Props {function HelpFeedbackPanel(props: Props) {const { t } = useTranslation();const theme = useTheme();- const {- toggleAboutDialog,- toggleKeysDialog,- toggleOnboardingDialog,- toggleProTeaser,- reduceHeightBy,- } = props;+ const { openAboutDialog } = useAboutDialogContext();+ const { openOnboardingDialog } = useOnboardingDialogContext();+ const { openKeyboardDialog } = useKeyboardDialogContext();+ const { openProTeaserDialog } = useProTeaserDialogContext();+ const { reduceHeightBy } = props;return (<SidePanel@@ -92,7 +90,7 @@ function HelpFeedbackPanel(props: Props) {}}><ListItem- onClick={toggleAboutDialog}+ onClick={() => openAboutDialog()}title="Opens the about dialog"data-tid="aboutDialog">@@ -115,7 +113,7 @@ function HelpFeedbackPanel(props: Props) {{t('core:documentation')}</Typography></ListItem>- <ListItem onClick={toggleKeysDialog}>+ <ListItem onClick={() => openKeyboardDialog()}><ListItemIcon><KeyShortcutsIcon /></ListItemIcon>@@ -134,7 +132,7 @@ function HelpFeedbackPanel(props: Props) {{t('core:whatsNew')}</Typography></ListItem>- <ListItem onClick={toggleOnboardingDialog}>+ <ListItem onClick={() => openOnboardingDialog()}><ListItemIcon><OnboardingIcon /></ListItemIcon>@@ -227,7 +225,7 @@ function HelpFeedbackPanel(props: Props) {</Typography></ListItem><Divider />- <ListItem onClick={() => toggleProTeaser()}>+ <ListItem onClick={() => openProTeaserDialog()}><ListItemIcon><ProTeaserIcon /></ListItemIcon>diff --git a/src/renderer/components/LocationManager.tsx b/src/renderer/components/LocationManager.tsxindex ec6b6953c..3ba63c087 100644--- a/src/renderer/components/LocationManager.tsx+++ b/src/renderer/components/LocationManager.tsx@@ -24,18 +24,18 @@ import LocationManagerMenu from '-/components/menus/LocationManagerMenu';import ConfirmDialog from '-/components/dialogs/ConfirmDialog';import { actions as LocationActions } from '-/reducers/locations';import { actions as AppActions, AppDispatch } from '-/reducers/app';-import LoadingLazy from '-/components/LoadingLazy';import LocationView from '-/components/LocationView';import { Pro } from '-/pro';import { classes, SidePanel } from '-/components/SidePanels.css';import { useTranslation } from 'react-i18next';import { useCurrentLocationContext } from '-/hooks/useCurrentLocationContext';import LocationContextMenu from '-/components/menus/LocationContextMenu';+import { useCreateEditLocationDialogContext } from '-/components/dialogs/hooks/useCreateEditLocationDialogContext';-const CreateEditLocationDialog = React.lazy(+/*const CreateEditLocationDialog = React.lazy(() =>import(- /* webpackChunkName: "CreateEditLocationDialog" */ './dialogs/CreateEditLocationDialog'+ /!* webpackChunkName: "CreateEditLocationDialog" *!/ './dialogs/CreateEditLocationDialog'),);function CreateEditLocationDialogAsync(props) {@@ -44,7 +44,7 @@ function CreateEditLocationDialogAsync(props) {<CreateEditLocationDialog {...props} /></React.Suspense>);-}+}*/interface Props {style?: any;@@ -59,18 +59,18 @@ function LocationManager(props: Props) {locations,currentLocation,addLocations,- editLocation,selectedLocation,setSelectedLocation,locationDirectoryContextMenuAnchorEl,} = useCurrentLocationContext();+ const { openCreateEditLocationDialog } = useCreateEditLocationDialogContext();//const locations: Array<CommonLocation> = useSelector(getLocations);// const loading: boolean = useSelector(isLoading);//const language: string = useSelector(getCurrentLanguage);const fileInputRef = useRef<HTMLInputElement>(null);- const [isEditLocationDialogOpened, setEditLocationDialogOpened] =- useState<boolean>(false);+ /*const [isEditLocationDialogOpened, setEditLocationDialogOpened] =+ useState<boolean>(false);*/const [isDeleteLocationDialogOpened, setDeleteLocationDialogOpened] =useState<boolean>(false);const [isExportLocationsDialogOpened, setExportLocationsDialogOpened] =@@ -153,13 +153,11 @@ function LocationManager(props: Props) {classes={classes}showCreateLocationDialog={() => {setSelectedLocation(undefined);- dispatch(AppActions.toggleLocationDialog());+ openCreateEditLocationDialog();}}- toggleOpenLinkDialog={() => dispatch(AppActions.toggleOpenLinkDialog())}/>{locationDirectoryContextMenuAnchorEl && (<LocationContextMenu- setEditLocationDialogOpened={setEditLocationDialogOpened}setDeleteLocationDialogOpened={setDeleteLocationDialogOpened}/>)}@@ -200,9 +198,6 @@ function LocationManager(props: Props) {<LocationViewkey={location.uuid}location={location}- setEditLocationDialogOpened={- setEditLocationDialogOpened- }setDeleteLocationDialogOpened={setDeleteLocationDialogOpened}@@ -224,13 +219,13 @@ function LocationManager(props: Props) {type="file"onChange={handleFileInputChange}/>- {isEditLocationDialogOpened && (+ {/*{isEditLocationDialogOpened && (<CreateEditLocationDialogAsyncopen={isEditLocationDialogOpened}onClose={() => setEditLocationDialogOpened(false)}editLocation={(location) => editLocation(location)}/>- )}+ )}*/}{isDeleteLocationDialogOpened && (<ConfirmDialogopen={isDeleteLocationDialogOpened}diff --git a/src/renderer/components/LocationView.tsx b/src/renderer/components/LocationView.tsxindex 36aa957fd..cc39abcab 100644--- a/src/renderer/components/LocationView.tsx+++ b/src/renderer/components/LocationView.tsx@@ -49,7 +49,6 @@ import { useEntryExistDialogContext } from '-/components/dialogs/hooks/useEntryEinterface Props {location: CommonLocation;hideDrawer?: () => void;- setEditLocationDialogOpened: (open: boolean) => void;setDeleteLocationDialogOpened: (open: boolean) => void;}diff --git a/src/renderer/components/MobileNavigation.tsx b/src/renderer/components/MobileNavigation.tsxindex 57bfd7eeb..27d676e59 100644--- a/src/renderer/components/MobileNavigation.tsx+++ b/src/renderer/components/MobileNavigation.tsx@@ -41,7 +41,6 @@ import {SettingsIcon,} from '-/components/CommonIcons';import AccountCircleIcon from '@mui/icons-material/AccountCircle';-import { CognitoUserInterface } from '@aws-amplify/ui-components';import Popover from '@mui/material/Popover';import { Pro } from '-/pro';import CustomLogo from '-/components/CustomLogo';@@ -58,16 +57,8 @@ import MenuItem from '@mui/material/MenuItem';import MenuList from '@mui/material/MenuList';import ListItemIcon from '@mui/material/ListItemIcon';import ListItemText from '@mui/material/ListItemText';-import {- actions as AppActions,- isLocationManagerPanelOpened,- isTagLibraryPanelOpened,- isSearchPanelOpened,- isHelpFeedbackPanelOpened,- AppDispatch,- currentUser,-} from '../reducers/app';-import { BetaLabel, ProLabel } from '-/components/HelperComponents';+import { AppDispatch } from '../reducers/app';+import { ProLabel } from '-/components/HelperComponents';import { actions as SettingsActions } from '-/reducers/settings';import StoredSearches from '-/components/StoredSearches';import UserDetailsPopover from '-/components/UserDetailsPopover';@@ -76,6 +67,14 @@ import { useTranslation } from 'react-i18next';import { getKeyBindingObject } from '-/reducers/settings';import { useCurrentLocationContext } from '-/hooks/useCurrentLocationContext';import { createNewInstance } from '-/services/utils-io';+import { useCreateEditLocationDialogContext } from '-/components/dialogs/hooks/useCreateEditLocationDialogContext';+import { useCreateDirectoryDialogContext } from '-/components/dialogs/hooks/useCreateDirectoryDialogContext';+import { useNewEntryDialogContext } from '-/components/dialogs/hooks/useNewEntryDialogContext';+import { useNewFileDialogContext } from '-/components/dialogs/hooks/useNewFileDialogContext';+import { useNewAudioDialogContext } from '-/components/dialogs/hooks/useNewAudioDialogContext';+import { useSettingsDialogContext } from '-/components/dialogs/hooks/useSettingsDialogContext';+import { usePanelsContext } from '-/hooks/usePanelsContext';+import { useUserContext } from '-/hooks/useUserContext';const PREFIX = 'MobileNavigation';@@ -104,16 +103,23 @@ function MobileNavigation(props: Props) {const dispatch: AppDispatch = useDispatch();const { setSelectedLocation } = useCurrentLocationContext();+ const { openNewEntryDialog } = useNewEntryDialogContext();+ const { openCreateEditLocationDialog } = useCreateEditLocationDialogContext();+ const { openCreateDirectoryDialog } = useCreateDirectoryDialogContext();+ const { openNewFileDialog } = useNewFileDialogContext();+ const { openNewAudioDialog } = useNewAudioDialogContext();+ const { openSettingsDialog } = useSettingsDialogContext();+ const { currentOpenedPanel, showPanel } = usePanelsContext();const keyBindings = useSelector(getKeyBindingObject);- const isLocationManagerPanelOpenedSelector = useSelector(+ /* const isLocationManagerPanelOpenedSelector = useSelector(isLocationManagerPanelOpened,);const isTagLibraryPanelOpenedSelector = useSelector(isTagLibraryPanelOpened);const isSearchPanelOpenedSelector = useSelector(isSearchPanelOpened);const isHelpFeedbackPanelOpenedSelector = useSelector(isHelpFeedbackPanelOpened,- );- const cognitoUser: CognitoUserInterface = useSelector(currentUser);+ );*/+ const { currentUser } = useUserContext();const [showTeaserBanner, setShowTeaserBanner] = useState<boolean>(true);const [anchorUser, setAnchorUser] = useState<HTMLButtonElement | null>(null);@@ -121,19 +127,12 @@ function MobileNavigation(props: Props) {const showProTeaser = !Pro && showTeaserBanner;const { hideDrawer, width } = props;- const toggleOnboardingDialog = () =>- dispatch(AppActions.toggleOnboardingDialog());- const toggleSettingsDialog = () =>- dispatch(AppActions.toggleSettingsDialog());- const toggleKeysDialog = () => dispatch(AppActions.toggleKeysDialog());- const toggleAboutDialog = () => dispatch(AppActions.toggleAboutDialog());- const openLocationManagerPanel = () =>+ /*const openLocationManagerPanel = () =>dispatch(AppActions.openLocationManagerPanel());const openTagLibraryPanel = () => dispatch(AppActions.openTagLibraryPanel());const openSearchPanel = () => dispatch(AppActions.openSearchPanel());const openHelpFeedbackPanel = () =>- dispatch(AppActions.openHelpFeedbackPanel());- const toggleProTeaser = () => dispatch(AppActions.toggleProTeaser());+ dispatch(AppActions.openHelpFeedbackPanel());*/const switchTheme = () => dispatch(SettingsActions.switchTheme());const [openedCreateMenu, setOpenCreateMenu] = React.useState(false);@@ -186,7 +185,7 @@ function MobileNavigation(props: Props) {size="small"data-tid="createNewFileTID"onClick={() => {- dispatch(AppActions.toggleNewEntryDialog());+ openNewEntryDialog();if (hideDrawer) {hideDrawer();}@@ -255,7 +254,7 @@ function MobileNavigation(props: Props) {key="createNewTextFileTID"ata-tid="createNewTextFileTID"onClick={() => {- dispatch(AppActions.toggleNewFileDialog());+ openNewFileDialog();setOpenCreateMenu(false);if (hideDrawer) {hideDrawer();@@ -271,7 +270,7 @@ function MobileNavigation(props: Props) {key="createNewFolderTID"ata-tid="createNewFolderTID"onClick={() => {- dispatch(AppActions.toggleCreateDirectoryDialog());+ openCreateDirectoryDialog();setOpenCreateMenu(false);if (hideDrawer) {hideDrawer();@@ -290,7 +289,7 @@ function MobileNavigation(props: Props) {data-tid="createNewAudioTID"disabled={!Pro}onClick={() => {- dispatch(AppActions.toggleNewAudioDialog());+ openNewAudioDialog();setOpenCreateMenu(false);if (hideDrawer) {hideDrawer();@@ -315,7 +314,7 @@ function MobileNavigation(props: Props) {ata-tid="createNewFolderTID"onClick={() => {setSelectedLocation(undefined);- dispatch(AppActions.toggleLocationDialog());+ openCreateEditLocationDialog();setOpenCreateMenu(false);if (hideDrawer) {hideDrawer();@@ -335,18 +334,16 @@ function MobileNavigation(props: Props) {</Popper><LocationManagerreduceHeightBy={140}- show={isLocationManagerPanelOpenedSelector}+ show={currentOpenedPanel === 'locationManagerPanel'}/>- {isTagLibraryPanelOpenedSelector && <TagLibrary reduceHeightBy={140} />}- {isSearchPanelOpenedSelector && <StoredSearches reduceHeightBy={140} />}- {isHelpFeedbackPanelOpenedSelector && (- <HelpFeedbackPanel- reduceHeightBy={150}- toggleAboutDialog={toggleAboutDialog}- toggleKeysDialog={toggleKeysDialog}- toggleOnboardingDialog={toggleOnboardingDialog}- toggleProTeaser={toggleProTeaser}- />+ {currentOpenedPanel === 'tagLibraryPanel' && (+ <TagLibrary reduceHeightBy={140} />+ )}+ {currentOpenedPanel === 'searchPanel' && (+ <StoredSearches reduceHeightBy={140} />+ )}+ {currentOpenedPanel === 'helpFeedbackPanel' && (+ <HelpFeedbackPanel reduceHeightBy={150} />)}</Box><Box@@ -355,17 +352,14 @@ function MobileNavigation(props: Props) {}}>{showProTeaser && (- <ProTeaser- toggleProTeaser={toggleProTeaser}- setShowTeaserBanner={setShowTeaserBanner}- />+ <ProTeaser setShowTeaserBanner={setShowTeaserBanner} />)}<Tooltip title={t('core:settings')}><IconButtonid="verticalNavButton"data-tid="settings"onClick={() => {- toggleSettingsDialog();+ openSettingsDialog();}}style={{ marginTop: -15, marginRight: 2 }}size="large"@@ -375,10 +369,10 @@ function MobileNavigation(props: Props) {</Tooltip><ToggleButtonGroup exclusive><ToggleButton- onClick={openLocationManagerPanel}+ onClick={() => showPanel('locationManagerPanel')}size="small"className={- isLocationManagerPanelOpenedSelector+ currentOpenedPanel === 'locationManagerPanel'? classNames(classes.button, classes.selectedButton): classes.button}@@ -394,10 +388,10 @@ function MobileNavigation(props: Props) {</ToggleButton><ToggleButtondata-tid="tagLibrary"- onClick={openTagLibraryPanel}+ onClick={() => showPanel('tagLibraryPanel')}size="small"className={- isTagLibraryPanelOpenedSelector+ currentOpenedPanel === 'tagLibraryPanel'? classNames(classes.button, classes.selectedButton): classes.button}@@ -413,9 +407,9 @@ function MobileNavigation(props: Props) {<ToggleButtondata-tid="quickAccessButton"size="small"- onClick={openSearchPanel}+ onClick={() => showPanel('searchPanel')}className={- isSearchPanelOpenedSelector+ currentOpenedPanel === 'searchPanel'? classNames(classes.button, classes.selectedButton): classes.button}@@ -427,10 +421,10 @@ function MobileNavigation(props: Props) {</ToggleButton><ToggleButtondata-tid="helpFeedback"- onClick={openHelpFeedbackPanel}+ onClick={() => showPanel('helpFeedbackPanel')}size="small"className={- isHelpFeedbackPanelOpenedSelector+ currentOpenedPanel === 'helpFeedbackPanel'? classNames(classes.button, classes.selectedButton): classes.button}@@ -441,7 +435,7 @@ function MobileNavigation(props: Props) {</Tooltip></ToggleButton></ToggleButtonGroup>- {cognitoUser ? (+ {currentUser ? (<><Tooltip title={t('core:userAccount')}><IconButtondiff --git a/src/renderer/components/ProTeaser.tsx b/src/renderer/components/ProTeaser.tsxindex f88837b0f..e4fa156e6 100644--- a/src/renderer/components/ProTeaser.tsx+++ b/src/renderer/components/ProTeaser.tsx@@ -27,20 +27,21 @@ import ProTeaserImage from '-/assets/images/pro-teaser.svg';import Links from 'assets/links';import { openURLExternally } from '-/services/utils-io';import { useTranslation } from 'react-i18next';+import { useProTeaserDialogContext } from '-/components/dialogs/hooks/useProTeaserDialogContext';interface Props {- toggleProTeaser: (slidePage?: string) => void;setShowTeaserBanner: (teaserVisibility: boolean) => void;}function ProTeaser(props: Props) {- const { toggleProTeaser, setShowTeaserBanner } = props;+ const { setShowTeaserBanner } = props;+ const { openProTeaserDialog } = useProTeaserDialogContext();const { t } = useTranslation();return (<><CardContent- onClick={() => toggleProTeaser()}+ onClick={() => openProTeaserDialog()}style={{padding: 5,paddingBottom: 0,@@ -80,7 +81,7 @@ function ProTeaser(props: Props) {onClick={(event: any) => {event.preventDefault();event.stopPropagation();- toggleProTeaser();+ openProTeaserDialog();}}>{t('showMeMore')}diff --git a/src/renderer/components/RenderPerspective.tsx b/src/renderer/components/RenderPerspective.tsxindex f252fef48..ff191f1ed 100644--- a/src/renderer/components/RenderPerspective.tsx+++ b/src/renderer/components/RenderPerspective.tsx@@ -28,7 +28,6 @@ import { SortedDirContextProvider } from '-/perspectives/grid/hooks/SortedDirConimport { PaginationContextProvider } from '-/hooks/PaginationContextProvider';import { ThumbGenerationContextProvider } from '-/hooks/ThumbGenerationContextProvider';import { PerspectiveSettingsContextProvider } from '-/hooks/PerspectiveSettingsContextProvider';-import { RendererListenerContextProvider } from '-/hooks/RendererListenerContextProvider';import { useCurrentLocationContext } from '-/hooks/useCurrentLocationContext';const GridPerspective = React.lazy(@@ -40,13 +39,11 @@ function GridPerspectiveAsync(props) {<React.Suspense fallback={<LoadingLazy />}><PerspectiveSettingsContextProvider><SortedDirContextProvider>- <RendererListenerContextProvider>- <PaginationContextProvider>- <ThumbGenerationContextProvider>- <GridPerspective {...props} />- </ThumbGenerationContextProvider>- </PaginationContextProvider>- </RendererListenerContextProvider>+ <PaginationContextProvider>+ <ThumbGenerationContextProvider>+ <GridPerspective {...props} />+ </ThumbGenerationContextProvider>+ </PaginationContextProvider></SortedDirContextProvider></PerspectiveSettingsContextProvider></React.Suspense>@@ -62,13 +59,11 @@ function ListPerspectiveAsync(props) {<React.Suspense fallback={<LoadingLazy />}><PerspectiveSettingsContextProvider><SortedDirContextProvider>- <RendererListenerContextProvider>- <PaginationContextProvider>- <ThumbGenerationContextProvider>- <ListPerspective {...props} />- </ThumbGenerationContextProvider>- </PaginationContextProvider>- </RendererListenerContextProvider>+ <PaginationContextProvider>+ <ThumbGenerationContextProvider>+ <ListPerspective {...props} />+ </ThumbGenerationContextProvider>+ </PaginationContextProvider></SortedDirContextProvider></PerspectiveSettingsContextProvider></React.Suspense>@@ -115,11 +110,9 @@ function KanBanPerspectiveAsync(props) {<React.Suspense fallback={<LoadingLazy />}><PerspectiveSettingsContextProvider><Pro.Perspectives.KanBanSortedDirContextProvider>- <RendererListenerContextProvider>- <ThumbGenerationContextProvider>- <KanBanPerspective {...props} />- </ThumbGenerationContextProvider>- </RendererListenerContextProvider>+ <ThumbGenerationContextProvider>+ <KanBanPerspective {...props} />+ </ThumbGenerationContextProvider></Pro.Perspectives.KanBanSortedDirContextProvider></PerspectiveSettingsContextProvider></React.Suspense>diff --git a/src/renderer/components/TagGroupContainer.tsx b/src/renderer/components/TagGroupContainer.tsxindex 3b327dc11..ae4ffa25f 100644--- a/src/renderer/components/TagGroupContainer.tsx+++ b/src/renderer/components/TagGroupContainer.tsx@@ -20,6 +20,7 @@ import React, { ReactNode, useRef } from 'react';import { DropTargetMonitor, useDrop } from 'react-dnd';import DragItemTypes from './DragItemTypes';import { TS } from '-/tagspaces.namespace';+import { dataTidFormat } from '-/services/test';interface Props {children: ReactNode;@@ -72,7 +73,7 @@ function TagGroupContainer(props: Props) {border,backgroundColor,}}- data-tid={'tagGroupContainer_' + props.taggroup.title}+ data-tid={'tagGroupContainer_' + dataTidFormat(props.taggroup.title)}>{props.children}</div>diff --git a/src/renderer/components/TargetFileBox.tsx b/src/renderer/components/TargetFileBox.tsxindex 395aaa88b..a01b99a6a 100644--- a/src/renderer/components/TargetFileBox.tsx+++ b/src/renderer/components/TargetFileBox.tsx@@ -31,6 +31,7 @@ import { useNotificationContext } from '-/hooks/useNotificationContext';import { useIOActionsContext } from '-/hooks/useIOActionsContext';import { useEditedEntryMetaContext } from '-/hooks/useEditedEntryMetaContext';import { useFileUploadDialogContext } from '-/components/dialogs/hooks/useFileUploadDialogContext';+import { useMoveOrCopyFilesDialogContext } from '-/components/dialogs/hooks/useMoveOrCopyFilesDialogContext';type DragItem = { files: File[]; items: DataTransferItemList };type DragProps = { isActive: boolean; handlerId: Identifier | null };@@ -38,7 +39,7 @@ type DragProps = { isActive: boolean; handlerId: Identifier | null };interface Props {children: ReactNode;accepts: Array<string>;- setMoveCopyDialogOpened: (files: Array<File>) => void;+ //setMoveCopyDialogOpened: (files: Array<File>) => void;}function TargetFileBox(props: Props) {@@ -51,8 +52,9 @@ function TargetFileBox(props: Props) {const { showNotification } = useNotificationContext();const { setReflectMetaActions } = useEditedEntryMetaContext();const { currentDirectoryPath } = useDirectoryContentContext();+ const { openMoveOrCopyFilesDialog } = useMoveOrCopyFilesDialogContext();const ref = useRef<HTMLDivElement>(null);- const { setMoveCopyDialogOpened } = props;+ //const { setMoveCopyDialogOpened } = props;const onUploadProgress = (progress, abort, fileName) => {dispatch(AppActions.onUploadProgress(progress, abort, fileName));@@ -115,7 +117,7 @@ function TargetFileBox(props: Props) {!currentLocation.haveObjectStoreSupport() &&!currentLocation.haveWebDavSupport()) {- return setMoveCopyDialogOpened(files);+ return openMoveOrCopyFilesDialog(files);} else {return handleCopyFiles(files);}diff --git a/src/renderer/components/UserDetailsPopover.tsx b/src/renderer/components/UserDetailsPopover.tsxindex 2f261148f..c0a0a9bbb 100644--- a/src/renderer/components/UserDetailsPopover.tsx+++ b/src/renderer/components/UserDetailsPopover.tsx@@ -18,7 +18,6 @@import React, { useState } from 'react';import classNames from 'classnames';-import { CognitoUserInterface } from '@aws-amplify/ui-components';import Typography from '@mui/material/Typography';import Box from '@mui/material/Box';import ListItem from '@mui/material/ListItem';@@ -31,9 +30,9 @@ import ExitToAppIcon from '@mui/icons-material/ExitToApp';import { useSelector } from 'react-redux';import { clearAllURLParams } from '-/utils/dom';import { Pro } from '-/pro';-import { currentUser } from '-/reducers/app';import { styled, useTheme } from '@mui/material/styles';import { useTranslation } from 'react-i18next';+import { useUserContext } from '-/hooks/useUserContext';const PREFIX = 'UserDetailsPopover';@@ -72,14 +71,15 @@ function UserDetailsPopover(props: Props) {const { t } = useTranslation();const theme = useTheme();const { onClose } = props;- const cognitoUser: CognitoUserInterface = useSelector(currentUser);+ const { currentUser } = useUserContext();+const [isSetupTOTPOpened, setSetupTOTPOpened] = useState<boolean>(false);const SetupTOTPDialog = Pro && Pro.UI ? Pro.UI.SetupTOTPDialog : false;let email;let initials;- if (cognitoUser && cognitoUser.attributes && cognitoUser.attributes.email) {- ({ email } = cognitoUser.attributes);+ if (currentUser && currentUser.attributes && currentUser.attributes.email) {+ ({ email } = currentUser.attributes);const fullName = email.split('@')[0].split('.');const firstName = fullName[0];const lastName = fullName[fullName.length - 1];@@ -140,7 +140,7 @@ function UserDetailsPopover(props: Props) {<SetupTOTPDialogopen={isSetupTOTPOpened}onClose={() => setSetupTOTPOpened(false)}- user={cognitoUser}+ user={currentUser}confirmCallback={(result) => {if (result) {window.location.reload(); // TODO SOFTWARE_TOKEN_MFA is not refreshed in signed user without window.reload()@@ -149,7 +149,7 @@ function UserDetailsPopover(props: Props) {}}/>)}- {'SOFTWARE_TOKEN_MFA'.indexOf(cognitoUser.preferredMFA) === -1 ? (+ {'SOFTWARE_TOKEN_MFA'.indexOf(currentUser.preferredMFA) === -1 ? (<Tooltip title={t('core:setupTOTPHelp')}><Buttondata-tid="setupTOTP"@@ -174,7 +174,7 @@ function UserDetailsPopover(props: Props) {className={classes.mainActionButton}onClick={async () => {try {- await Auth.setPreferredMFA(cognitoUser, 'NOMFA');+ await Auth.setPreferredMFA(currentUser, 'NOMFA');signOut();} catch (error) {console.log(error);diff --git a/src/renderer/components/WelcomePanel.tsx b/src/renderer/components/WelcomePanel.tsxindex bce5ba6d0..22d6082b9 100644--- a/src/renderer/components/WelcomePanel.tsx+++ b/src/renderer/components/WelcomePanel.tsx@@ -52,6 +52,11 @@ import { openURLExternally } from '-/services/utils-io';import { styled, useTheme } from '@mui/material/styles';import { useTranslation } from 'react-i18next';import RenderHistory from '-/components/RenderHistory';+import { useCreateEditLocationDialogContext } from '-/components/dialogs/hooks/useCreateEditLocationDialogContext';+import { useNewFileDialogContext } from '-/components/dialogs/hooks/useNewFileDialogContext';+import { useAboutDialogContext } from '-/components/dialogs/hooks/useAboutDialogContext';+import { useKeyboardDialogContext } from '-/components/dialogs/hooks/useKeyboardDialogContext';+import { useLinkDialogContext } from '-/components/dialogs/hooks/useLinkDialogContext';const PREFIX = 'WelcomePanel';@@ -83,22 +88,17 @@ const Root = styled('div')(({ theme }) => ({function WelcomePanel() {const { t } = useTranslation();const theme = useTheme();+ const { openCreateEditLocationDialog } = useCreateEditLocationDialogContext();+ const { openNewFileDialog } = useNewFileDialogContext();+ const { openAboutDialog } = useAboutDialogContext();+ const { openKeyboardDialog } = useKeyboardDialogContext();+ const { openLinkDialog } = useLinkDialogContext();const historyContext = Pro?.contextProviders?.HistoryContext? useContext<TS.HistoryContextData>(Pro.contextProviders.HistoryContext): undefined;- const dispatch: AppDispatch = useDispatch();const desktopMode = useSelector(getDesktopMode);- const toggleNewFileDialogDispatch = () =>- dispatch(AppActions.toggleNewFileDialog());- const toggleLocationDialogDispatch = () =>- dispatch(AppActions.toggleLocationDialog());- const toggleOpenLinkDialogDispatch = () =>- dispatch(AppActions.toggleOpenLinkDialog());- const toggleKeysDialogDispatch = () =>- dispatch(AppActions.toggleKeysDialog());-- const [ignored, forceUpdate] = useReducer((x) => x + 1, 0);+ const [ignored, forceUpdate] = useReducer((x) => x + 1, 0, undefined);const historyKeys = Pro ? Pro.keys.historyKeys : {};const fileOpenHistoryItems: Array<TS.HistoryItem> = Pro@@ -207,7 +207,7 @@ function WelcomePanel() {role="button"aria-hidden="true"tabIndex={0}- onClick={() => dispatch(AppActions.toggleAboutDialog())}+ onClick={() => openAboutDialog()}><img src={WelcomeLogo} alt="Organize your files" /></div>@@ -220,7 +220,7 @@ function WelcomePanel() {className={classes.listItem}/></ListItem> */}- <ListItem onClick={toggleNewFileDialogDispatch}>+ <ListItem onClick={() => openNewFileDialog()}><ListItemIcon><CreateFileIcon /></ListItemIcon>@@ -229,7 +229,7 @@ function WelcomePanel() {className={classes.listItem}/></ListItem>- <ListItem onClick={toggleLocationDialogDispatch}>+ <ListItem onClick={() => openCreateEditLocationDialog()}><ListItemIcon><LocalLocationIcon /></ListItemIcon>@@ -238,7 +238,7 @@ function WelcomePanel() {className={classes.listItem}/></ListItem>- <ListItem onClick={toggleOpenLinkDialogDispatch}>+ <ListItem onClick={() => openLinkDialog()}><ListItemIcon><OpenLinkIcon /></ListItemIcon>@@ -258,7 +258,7 @@ function WelcomePanel() {className={classes.listItem}/></ListItem>- <ListItem onClick={toggleKeysDialogDispatch}>+ <ListItem onClick={() => openKeyboardDialog()}><ListItemIcon><KeyShortcutsIcon /></ListItemIcon>diff --git a/src/renderer/components/dialogs/AboutDialog.tsx b/src/renderer/components/dialogs/AboutDialog.tsxindex a4a2b0ca1..159a74dd5 100644--- a/src/renderer/components/dialogs/AboutDialog.tsx+++ b/src/renderer/components/dialogs/AboutDialog.tsx@@ -38,11 +38,11 @@ import { useTheme } from '@mui/material/styles';import AppConfig from '-/AppConfig';import { openURLExternally } from '-/services/utils-io';import { useTranslation } from 'react-i18next';+import { useLicenseDialogContext } from '-/components/dialogs/hooks/useLicenseDialogContext';+import { useThirdPartyLibsDialogContext } from '-/components/dialogs/hooks/useThirdPartyLibsDialogContext';interface Props {open: boolean;- toggleLicenseDialog: () => void;- toggleThirdPartyLibsDialog: () => void;onClose: () => void;}@@ -56,6 +56,8 @@ document.title = productName + ' ' + versionMeta.version;function AboutDialog(props: Props) {const { t } = useTranslation();+ const { openLicenseDialog } = useLicenseDialogContext();+ const { openThirdPartyLibsDialog } = useThirdPartyLibsDialogContext();const [updateAvailable, setUpdateAvailable] = useState(false);const [newVersion, setNewVersion] = useState('');const { open, onClose } = props;@@ -163,7 +165,7 @@ function AboutDialog(props: Props) {size="small"color="primary"style={{ marginLeft: -5 }}- onClick={props.toggleThirdPartyLibsDialog}+ onClick={() => openThirdPartyLibsDialog()}>Software Acknowledgements</Button>@@ -217,7 +219,7 @@ function AboutDialog(props: Props) {size="small"color="primary"data-tid="openLicenseDialog"- onClick={props.toggleLicenseDialog}+ onClick={() => openLicenseDialog()}>License Agreement</Button>diff --git a/src/renderer/components/dialogs/CreateEditLocationDialog.tsx b/src/renderer/components/dialogs/CreateEditLocationDialog.tsxindex baa0a6a60..73a872de2 100644--- a/src/renderer/components/dialogs/CreateEditLocationDialog.tsx+++ b/src/renderer/components/dialogs/CreateEditLocationDialog.tsx@@ -92,7 +92,7 @@ const StyledDialog = styled(Dialog)(({ theme }) => ({interface Props {open: boolean;onClose: () => void;- editLocation?: (location: CommonLocation) => void;+ //editLocation?: (location: CommonLocation) => void;}function CreateEditLocationDialog(props: Props) {@@ -101,7 +101,7 @@ function CreateEditLocationDialog(props: Props) {const { showNotification } = useNotificationContext();const { createLocationIndex } = useLocationIndexContext();const { loadLocationDataPromise } = useTagGroupsLocationContext();- const { addLocation, selectedLocation, findLocation } =+ const { addLocation, editLocation, selectedLocation, findLocation } =useCurrentLocationContext();const isPersistTagsInSidecar = useSelector(getPersistTagsInSidecarFile);//const locations: Array<CommonLocation> = useSelector(getLocations);@@ -448,12 +448,12 @@ function CreateEditLocationDialog(props: Props) {}addLocation(commonLocation);});- } else if (props.editLocation) {- loc.newuuid = newuuid;- props.editLocation(new CommonLocation(loc));} else {+ loc.newuuid = newuuid;+ editLocation(new CommonLocation(loc));+ } /*else {console.log('No addLocation or editLocation props exist');- }+ }*/onClose();// this.props.resetState('createLocationDialogKey');}@@ -904,7 +904,7 @@ function CreateEditLocationDialog(props: Props) {</ToggleButton><ToggleButtonvalue={false}- data-tid="settingsSetPersistTagsInFileName"+ data-tid="locationSetPersistTagsInFileName"onClick={() => setPersistTagsInSidecarFile(false)}><Tooltip@@ -923,7 +923,7 @@ function CreateEditLocationDialog(props: Props) {</ToggleButton><ToggleButtonvalue={true}- data-tid="settingsSetPersistTagsInSidecarFile"+ data-tid="locationSetPersistTagsInSidecarFile"onClick={() => setPersistTagsInSidecarFile(true)}><Tooltipdiff --git a/src/renderer/components/dialogs/EditEntryTagDialog.tsx b/src/renderer/components/dialogs/EditEntryTagDialog.tsxindex 8beb62f30..8eb0d5330 100644--- a/src/renderer/components/dialogs/EditEntryTagDialog.tsx+++ b/src/renderer/components/dialogs/EditEntryTagDialog.tsx@@ -34,7 +34,6 @@ import Dialog from '@mui/material/Dialog';import EditIcon from '@mui/icons-material/Edit';import { isGeoTag } from '-/utils/geo';import { Pro } from '-/pro';-import { getSelectedTag } from '-/reducers/app';import { isDateTimeTag } from '-/utils/dates';import { TS } from '-/tagspaces.namespace';import useValidation from '-/utils/useValidation';@@ -43,10 +42,10 @@ import { useTheme } from '@mui/material/styles';import useMediaQuery from '@mui/material/useMediaQuery';import { useTranslation } from 'react-i18next';import { useTaggingActionsContext } from '-/hooks/useTaggingActionsContext';-import { useSelector } from 'react-redux';interface Props {open: boolean;+ tag: TS.Tag;onClose: () => void;}@@ -56,10 +55,12 @@ const DateTagEditor = Pro && Pro.UI ? Pro.UI.DateTagEditor : React.Fragment;function EditEntryTagDialog(props: Props) {const { t } = useTranslation();+ const { onClose, open, tag } = props;+const { addTagsToEntry, editTagForEntry } = useTaggingActionsContext();- const selectedTag: TS.Tag = useSelector(getSelectedTag);+ // const selectedTag: TS.Tag = useSelector(getSelectedTag);const [showAdvancedMode, setShowAdvancedMode] = useState<boolean>(false);- const [title, setTitle] = useState(selectedTag && selectedTag.title);+ const [title, setTitle] = useState(tag && tag.title);const titleRef = useRef<HTMLInputElement>(null);const isShowDatePeriodEditor = useMemo(() => {@@ -83,7 +84,6 @@ function EditEntryTagDialog(props: Props) {isShowDatePeriodEditor,);const { setError, haveError } = useValidation();- const { onClose, open } = props;useEffect(() => {if (titleRef && titleRef.current) {@@ -105,11 +105,11 @@ function EditEntryTagDialog(props: Props) {function onConfirm() {if (handleValidation() && !haveError()) {- const isNew = selectedTag.functionality === 'geoTagging'; //path.includes(props.selectedTag.title);+ const isNew = tag.functionality === 'geoTagging'; //path.includes(props.selectedTag.title);if (isNew) {- addTagsToEntry(selectedTag.path, [{ ...selectedTag, title }]);+ addTagsToEntry(tag.path, [{ ...tag, title }]);} else {- editTagForEntry(selectedTag.path, selectedTag, title);+ editTagForEntry(tag.path, tag, title);}props.onClose();}@@ -171,10 +171,7 @@ function EditEntryTagDialog(props: Props) {/>)}{editDisabled && isShowDatePeriodEditor && (- <DateTagEditor- datePeriodTag={selectedTag && selectedTag.title}- onChange={setTitle}- />+ <DateTagEditor datePeriodTag={tag && tag.title} onChange={setTitle} />)}</DialogContent>);diff --git a/src/renderer/components/dialogs/FilePreviewDialog.tsx b/src/renderer/components/dialogs/FilePreviewDialog.tsxindex cf3dbab31..6566efddc 100644--- a/src/renderer/components/dialogs/FilePreviewDialog.tsx+++ b/src/renderer/components/dialogs/FilePreviewDialog.tsx@@ -32,6 +32,7 @@ import useEventListener from '-/utils/useEventListener';import AppConfig from '-/AppConfig';import { useCurrentLocationContext } from '-/hooks/useCurrentLocationContext';import { useOpenedEntryContext } from '-/hooks/useOpenedEntryContext';+import { useFilePropertiesContext } from '-/hooks/useFilePropertiesContext';interface Props {open: boolean;@@ -43,6 +44,7 @@ function FilePreviewDialog(props: Props) {const { open = false, onClose, fsEntry } = props;const { findLocation } = useCurrentLocationContext();const { openedEntry } = useOpenedEntryContext();+ const { isEditMode } = useFilePropertiesContext();// const supportedFileTypes = useSelector(getSupportedFileTypes);const currentTheme = useSelector(getCurrentTheme);const fileViewer: MutableRefObject<HTMLIFrameElement> =@@ -58,7 +60,7 @@ function FilePreviewDialog(props: Props) {...(fsEntry.uuid && { uuid: fsEntry.uuid }),path: fsEntry.path,isFile: fsEntry.isFile,- editMode: false,+ // editMode: false,}: undefined;@@ -137,7 +139,7 @@ function FilePreviewDialog(props: Props) {fileViewer.current.contentWindow.setContent(content,fileDirectory,- !openedFile.editMode,+ !isEditMode,currentTheme,);}@@ -190,7 +192,6 @@ function FilePreviewDialog(props: Props) {fileViewerContainer={fileViewerContainer}height={'90%'}eventID={eventID.current}- isFileChanged={false}/></DialogContent></Dialog>diff --git a/src/renderer/components/dialogs/OpenLinkDialog.tsx b/src/renderer/components/dialogs/OpenLinkDialog.tsxindex 2b130c17d..5f72cbab7 100644--- a/src/renderer/components/dialogs/OpenLinkDialog.tsx+++ b/src/renderer/components/dialogs/OpenLinkDialog.tsx@@ -117,7 +117,7 @@ function OpenLinkDialog(props: Props) {setLinkURL(target.value);}}value={linkURL}- data-tid="directoryName"+ data-tid="openLinkTID"InputProps={{endAdornment: (<InputAdornment position="start">diff --git a/src/renderer/components/dialogs/ProTeaserDialog.tsx b/src/renderer/components/dialogs/ProTeaserDialog.tsxindex f699ecdce..d9967c289 100644--- a/src/renderer/components/dialogs/ProTeaserDialog.tsx+++ b/src/renderer/components/dialogs/ProTeaserDialog.tsx@@ -25,8 +25,6 @@ import Dialog from '@mui/material/Dialog';import DialogCloseButton from '-/components/dialogs/DialogCloseButton';import { useTheme } from '@mui/material/styles';import useMediaQuery from '@mui/material/useMediaQuery';-import { getProTeaserIndex } from '-/reducers/app';-import { useSelector } from 'react-redux';import { getProTeaserSlides } from '-/content/ProTeaserSlides';import Links from 'assets/links';import { openURLExternally } from '-/services/utils-io';@@ -37,6 +35,7 @@ import NavigateBeforeIcon from '@mui/icons-material/NavigateBefore';interface Props {open: boolean;+ slideIndex: number;onClose: () => void;}@@ -157,11 +156,11 @@ function Slide(props: SlideProps) {function ProTeaserDialog(props: Props) {const { t } = useTranslation();//const swiperElRef = useRef(null); //<SwiperRef>- const slideIndex = useSelector(getProTeaserIndex);+ //const slideIndex = useSelector(getProTeaserIndex);const slidesEN = getProTeaserSlides(t);- const { open, onClose } = props;+ const { open, onClose, slideIndex } = props;const theme = useTheme();const fullScreen = useMediaQuery(theme.breakpoints.down('md'));diff --git a/src/renderer/components/dialogs/components/CreateDirectory.tsx b/src/renderer/components/dialogs/components/CreateDirectory.tsxindex c978f785e..584a9388b 100644--- a/src/renderer/components/dialogs/components/CreateDirectory.tsx+++ b/src/renderer/components/dialogs/components/CreateDirectory.tsx@@ -36,9 +36,12 @@ import { useTranslation } from 'react-i18next';import { useIOActionsContext } from '-/hooks/useIOActionsContext';import { useNotificationContext } from '-/hooks/useNotificationContext';import { Pro } from '-/pro';-import { BetaLabel, ProLabel } from '-/components/HelperComponents';+import { ProLabel } from '-/components/HelperComponents';import { useCurrentLocationContext } from '-/hooks/useCurrentLocationContext';import { useFileUploadDialogContext } from '-/components/dialogs/hooks/useFileUploadDialogContext';+import { useCreateEditLocationDialogContext } from '-/components/dialogs/hooks/useCreateEditLocationDialogContext';+import { useCreateDirectoryDialogContext } from '-/components/dialogs/hooks/useCreateDirectoryDialogContext';+import { useNewAudioDialogContext } from '-/components/dialogs/hooks/useNewAudioDialogContext';const PREFIX = 'CreateDirectory';@@ -65,6 +68,9 @@ function CreateDirectory(props: Props) {const { downloadFile } = useIOActionsContext();const { showNotification } = useNotificationContext();const { openFileUploadDialog } = useFileUploadDialogContext();+ const { openCreateEditLocationDialog } = useCreateEditLocationDialogContext();+ const { openCreateDirectoryDialog } = useCreateDirectoryDialogContext();+ const { openNewAudioDialog } = useNewAudioDialogContext();const fileUploadContainerRef = useRef<FileUploadContainerRef>(null);const dispatch: AppDispatch = useDispatch();@@ -172,7 +178,7 @@ function CreateDirectory(props: Props) {variant="outlined"onClick={() => {onClose();- dispatch(AppActions.toggleLocationDialog());+ openCreateEditLocationDialog();}}className={classes.createButton}data-tid={tid('createLocationButton')}@@ -189,7 +195,7 @@ function CreateDirectory(props: Props) {variant="outlined"onClick={() => {onClose();- dispatch(AppActions.toggleCreateDirectoryDialog());+ openCreateDirectoryDialog();}}className={classes.createButton}data-tid={tid('newSubDirTID')}@@ -204,7 +210,7 @@ function CreateDirectory(props: Props) {disabled={!Pro || noSuitableLocation}onClick={() => {onClose();- dispatch(AppActions.toggleNewAudioDialog());+ openNewAudioDialog();}}className={classes.createButton}data-tid={tid('newSubDirTID')}diff --git a/src/renderer/components/dialogs/hooks/AboutDialogContextProvider.tsx b/src/renderer/components/dialogs/hooks/AboutDialogContextProvider.tsxnew file mode 100644index 000000000..d6133981d--- /dev/null+++ b/src/renderer/components/dialogs/hooks/AboutDialogContextProvider.tsx@@ -0,0 +1,101 @@+/**+ * TagSpaces - universal file and folder organizer+ * Copyright (C) 2017-present TagSpaces UG (haftungsbeschraenkt)+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License (version 3) as+ * published by the Free Software Foundation.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <https://www.gnu.org/licenses/>.+ *+ */++import React, {+ createContext,+ useEffect,+ useMemo,+ useReducer,+ useRef,+} from 'react';+import LoadingLazy from '-/components/LoadingLazy';+import AppConfig from '-/AppConfig';++type AboutDialogContextData = {+ openAboutDialog: () => void;+ closeAboutDialog: () => void;+};++export const AboutDialogContext = createContext<AboutDialogContextData>({+ openAboutDialog: undefined,+ closeAboutDialog: undefined,+});++export type AboutDialogContextProviderProps = {+ children: React.ReactNode;+};++const AboutDialog = React.lazy(+ () => import(/* webpackChunkName: "AboutDialog" */ '../AboutDialog'),+);++export const AboutDialogContextProvider = ({+ children,+}: AboutDialogContextProviderProps) => {+ const open = useRef<boolean>(false);++ const [ignored, forceUpdate] = useReducer((x) => x + 1, 0, undefined);++ useEffect(() => {+ if (AppConfig.isElectron) {+ window.electronIO.ipcRenderer.on('cmd', (arg) => {+ if (arg === 'toggle-about-dialog') {+ openDialog();+ }+ });++ return () => {+ if (window.electronIO.ipcRenderer) {+ window.electronIO.ipcRenderer.removeAllListeners('cmd');+ }+ };+ }+ }, []);++ function openDialog() {+ open.current = true;+ forceUpdate();+ }++ function closeDialog() {+ open.current = false;+ forceUpdate();+ }++ function AboutDialogAsync(props) {+ return (+ <React.Suspense fallback={<LoadingLazy />}>+ <AboutDialog {...props} />+ </React.Suspense>+ );+ }++ const context = useMemo(() => {+ return {+ openAboutDialog: openDialog,+ closeAboutDialog: closeDialog,+ };+ }, []);++ return (+ <AboutDialogContext.Provider value={context}>+ <AboutDialogAsync open={open.current} onClose={closeDialog} />+ {children}+ </AboutDialogContext.Provider>+ );+};diff --git a/src/renderer/components/dialogs/hooks/CreateDirectoryDialogContextProvider.tsx b/src/renderer/components/dialogs/hooks/CreateDirectoryDialogContextProvider.tsxnew file mode 100644index 000000000..1f7b40c3c--- /dev/null+++ b/src/renderer/components/dialogs/hooks/CreateDirectoryDialogContextProvider.tsx@@ -0,0 +1,122 @@+/**+ * TagSpaces - universal file and folder organizer+ * Copyright (C) 2017-present TagSpaces UG (haftungsbeschraenkt)+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License (version 3) as+ * published by the Free Software Foundation.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <https://www.gnu.org/licenses/>.+ *+ */++import React, {+ createContext,+ useEffect,+ useMemo,+ useReducer,+ useRef,+} from 'react';+import LoadingLazy from '-/components/LoadingLazy';+import AppConfig from '-/AppConfig';++type CreateDirectoryDialogContextData = {+ openCreateDirectoryDialog: (+ selectedDirectoryPath?: string,+ callback?: (newDirPath: string) => void,+ ) => void;+ closeCreateDirectoryDialog: () => void;+};++export const CreateDirectoryDialogContext =+ createContext<CreateDirectoryDialogContextData>({+ openCreateDirectoryDialog: undefined,+ closeCreateDirectoryDialog: undefined,+ });++export type CreateDirectoryDialogContextProviderProps = {+ children: React.ReactNode;+};++const CreateDirectoryDialog = React.lazy(+ () =>+ import(+ /* webpackChunkName: "CreateDirectoryDialog" */ '../CreateDirectoryDialog'+ ),+);++export const CreateDirectoryDialogContextProvider = ({+ children,+}: CreateDirectoryDialogContextProviderProps) => {+ const open = useRef<boolean>(false);+ const selectedDirectoryPath = useRef<string>(undefined);+ const callbackFn = useRef<(newDirPath: string) => void>(undefined);++ const [ignored, forceUpdate] = useReducer((x) => x + 1, 0, undefined);++ useEffect(() => {+ if (AppConfig.isElectron) {+ window.electronIO.ipcRenderer.on('cmd', (arg) => {+ if (arg === 'show-create-directory-dialog') {+ openDialog(undefined, (dirPath) => {+ console.log(dirPath);+ });+ }+ });++ return () => {+ if (window.electronIO.ipcRenderer) {+ window.electronIO.ipcRenderer.removeAllListeners('cmd');+ }+ };+ }+ }, []);++ function openDialog(+ directoryPath: string,+ callback: (newDirPath: string) => void,+ ) {+ open.current = true;+ selectedDirectoryPath.current = directoryPath;+ callbackFn.current = callback;+ forceUpdate();+ }++ function closeDialog() {+ open.current = false;+ forceUpdate();+ }++ function CreateDirectoryDialogAsync(props) {+ return (+ <React.Suspense fallback={<LoadingLazy />}>+ <CreateDirectoryDialog {...props} />+ </React.Suspense>+ );+ }++ const context = useMemo(() => {+ return {+ openCreateDirectoryDialog: openDialog,+ closeCreateDirectoryDialog: closeDialog,+ };+ }, []);++ return (+ <CreateDirectoryDialogContext.Provider value={context}>+ <CreateDirectoryDialogAsync+ open={open.current}+ onClose={closeDialog}+ selectedDirectoryPath={selectedDirectoryPath.current}+ callback={callbackFn.current}+ />+ {children}+ </CreateDirectoryDialogContext.Provider>+ );+};diff --git a/src/renderer/components/dialogs/hooks/CreateEditLocationDialogContextProvider.tsx b/src/renderer/components/dialogs/hooks/CreateEditLocationDialogContextProvider.tsxnew file mode 100644index 000000000..d450c20d4--- /dev/null+++ b/src/renderer/components/dialogs/hooks/CreateEditLocationDialogContextProvider.tsx@@ -0,0 +1,85 @@+/**+ * TagSpaces - universal file and folder organizer+ * Copyright (C) 2017-present TagSpaces UG (haftungsbeschraenkt)+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License (version 3) as+ * published by the Free Software Foundation.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <https://www.gnu.org/licenses/>.+ *+ */++import React, { createContext, useMemo, useReducer, useRef } from 'react';+import LoadingLazy from '-/components/LoadingLazy';++type CreateEditLocationDialogContextData = {+ openCreateEditLocationDialog: () => void;+ closeCreateEditLocationDialog: () => void;+};++export const CreateEditLocationDialogContext =+ createContext<CreateEditLocationDialogContextData>({+ openCreateEditLocationDialog: undefined,+ closeCreateEditLocationDialog: undefined,+ });++export type CreateEditLocationDialogContextProviderProps = {+ children: React.ReactNode;+};++const CreateEditLocationDialog = React.lazy(+ () =>+ import(+ /* webpackChunkName: "CreateEditLocationDialog" */ '../CreateEditLocationDialog'+ ),+);++export const CreateEditLocationDialogContextProvider = ({+ children,+}: CreateEditLocationDialogContextProviderProps) => {+ const open = useRef<boolean>(false);++ const [ignored, forceUpdate] = useReducer((x) => x + 1, 0, undefined);++ function openDialog() {+ open.current = true;+ forceUpdate();+ }++ function closeDialog() {+ open.current = false;+ forceUpdate();+ }++ function CreateEditLocationDialogAsync(props) {+ return (+ <React.Suspense fallback={<LoadingLazy />}>+ <CreateEditLocationDialog {...props} />+ </React.Suspense>+ );+ }++ const context = useMemo(() => {+ return {+ openCreateEditLocationDialog: openDialog,+ closeCreateEditLocationDialog: closeDialog,+ };+ }, []);++ return (+ <CreateEditLocationDialogContext.Provider value={context}>+ <CreateEditLocationDialogAsync+ open={open.current}+ onClose={closeDialog}+ />+ {children}+ </CreateEditLocationDialogContext.Provider>+ );+};diff --git a/src/renderer/components/dialogs/hooks/DeleteMultipleEntriesDialogContextProvider.tsx b/src/renderer/components/dialogs/hooks/DeleteMultipleEntriesDialogContextProvider.tsxnew file mode 100644index 000000000..4a36b99ed--- /dev/null+++ b/src/renderer/components/dialogs/hooks/DeleteMultipleEntriesDialogContextProvider.tsx@@ -0,0 +1,119 @@+/**+ * TagSpaces - universal file and folder organizer+ * Copyright (C) 2017-present TagSpaces UG (haftungsbeschraenkt)+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License (version 3) as+ * published by the Free Software Foundation.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <https://www.gnu.org/licenses/>.+ *+ */++import React, { createContext, useMemo, useReducer, useRef } from 'react';+import { useTranslation } from 'react-i18next';+import LoadingLazy from '-/components/LoadingLazy';+import { useSelectedEntriesContext } from '-/hooks/useSelectedEntriesContext';+import { useIOActionsContext } from '-/hooks/useIOActionsContext';+import { useNotificationContext } from '-/hooks/useNotificationContext';++type DeleteMultipleEntriesDialogContextData = {+ openDeleteMultipleEntriesDialog: () => void;+ closeDeleteMultipleEntriesDialog: () => void;+};++export const DeleteMultipleEntriesDialogContext =+ createContext<DeleteMultipleEntriesDialogContextData>({+ openDeleteMultipleEntriesDialog: undefined,+ closeDeleteMultipleEntriesDialog: undefined,+ });++export type DeleteMultipleEntriesDialogContextProviderProps = {+ children: React.ReactNode;+};++const DeleteMultipleEntriesDialog = React.lazy(+ () =>+ import(+ /* webpackChunkName: "DeleteMultipleEntriesDialog" */ '../ConfirmDialog'+ ),+);++export const DeleteMultipleEntriesDialogContextProvider = ({+ children,+}: DeleteMultipleEntriesDialogContextProviderProps) => {+ const { t } = useTranslation();+ const { deleteEntries } = useIOActionsContext();+ const { selectedEntries } = useSelectedEntriesContext();+ const { showNotification } = useNotificationContext();+ const open = useRef<boolean>(false);++ const [ignored, forceUpdate] = useReducer((x) => x + 1, 0, undefined);++ function openDialog() {+ open.current = true;+ forceUpdate();+ }++ function closeDialog() {+ open.current = false;+ forceUpdate();+ }++ function DeleteMultipleEntriesDialogAsync(props) {+ return (+ <React.Suspense fallback={<LoadingLazy />}>+ <DeleteMultipleEntriesDialog {...props} />+ </React.Suspense>+ );+ }++ const context = useMemo(() => {+ return {+ openDeleteMultipleEntriesDialog: openDialog,+ closeDeleteMultipleEntriesDialog: closeDialog,+ };+ }, [selectedEntries]);++ function deleteSelectedEntries() {+ if (selectedEntries) {+ deleteEntries(...selectedEntries).then(+ (success) =>+ success &&+ selectedEntries.length > 1 &&+ showNotification(+ t('core:deletingEntriesSuccessful', {+ dirPath: selectedEntries+ .map((fsEntry) => fsEntry.name)+ .toString(),+ }),+ 'default',+ true,+ ),+ );+ }+ }++ return (+ <DeleteMultipleEntriesDialogContext.Provider value={context}>+ <DeleteMultipleEntriesDialogAsync+ open={open.current}+ onClose={closeDialog}+ title={t('core:deleteConfirmationTitle')}+ content={t('core:deleteConfirmationContent')}+ list={selectedEntries.map((fsEntry) => fsEntry.name)}+ confirmCallback={(result) => result && deleteSelectedEntries()}+ cancelDialogTID="cancelDeleteFileDialog"+ confirmDialogTID="confirmDeleteFileDialog"+ confirmDialogContentTID="confirmDeleteDialogContent"+ />+ {children}+ </DeleteMultipleEntriesDialogContext.Provider>+ );+};diff --git a/src/renderer/components/dialogs/hooks/KeyboardDialogContextProvider.tsx b/src/renderer/components/dialogs/hooks/KeyboardDialogContextProvider.tsxnew file mode 100644index 000000000..c157b7e94--- /dev/null+++ b/src/renderer/components/dialogs/hooks/KeyboardDialogContextProvider.tsx@@ -0,0 +1,101 @@+/**+ * TagSpaces - universal file and folder organizer+ * Copyright (C) 2017-present TagSpaces UG (haftungsbeschraenkt)+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License (version 3) as+ * published by the Free Software Foundation.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <https://www.gnu.org/licenses/>.+ *+ */++import React, {+ createContext,+ useEffect,+ useMemo,+ useReducer,+ useRef,+} from 'react';+import LoadingLazy from '-/components/LoadingLazy';+import AppConfig from '-/AppConfig';++type KeyboardDialogContextData = {+ openKeyboardDialog: () => void;+ closeKeyboardDialog: () => void;+};++export const KeyboardDialogContext = createContext<KeyboardDialogContextData>({+ openKeyboardDialog: undefined,+ closeKeyboardDialog: undefined,+});++export type KeyboardDialogContextProviderProps = {+ children: React.ReactNode;+};++const KeyboardDialog = React.lazy(+ () => import(/* webpackChunkName: "KeyboardDialog" */ '../KeyboardDialog'),+);++export const KeyboardDialogContextProvider = ({+ children,+}: KeyboardDialogContextProviderProps) => {+ const open = useRef<boolean>(false);++ const [ignored, forceUpdate] = useReducer((x) => x + 1, 0, undefined);++ useEffect(() => {+ if (AppConfig.isElectron) {+ window.electronIO.ipcRenderer.on('cmd', (arg) => {+ if (arg === 'toggle-keys-dialog') {+ openDialog();+ }+ });++ return () => {+ if (window.electronIO.ipcRenderer) {+ window.electronIO.ipcRenderer.removeAllListeners('cmd');+ }+ };+ }+ }, []);++ function openDialog() {+ open.current = true;+ forceUpdate();+ }++ function closeDialog() {+ open.current = false;+ forceUpdate();+ }++ function KeyboardDialogAsync(props) {+ return (+ <React.Suspense fallback={<LoadingLazy />}>+ <KeyboardDialog {...props} />+ </React.Suspense>+ );+ }++ const context = useMemo(() => {+ return {+ openKeyboardDialog: openDialog,+ closeKeyboardDialog: closeDialog,+ };+ }, []);++ return (+ <KeyboardDialogContext.Provider value={context}>+ <KeyboardDialogAsync open={open.current} onClose={closeDialog} />+ {children}+ </KeyboardDialogContext.Provider>+ );+};diff --git a/src/renderer/components/dialogs/hooks/LicenseDialogContextProvider.tsx b/src/renderer/components/dialogs/hooks/LicenseDialogContextProvider.tsxnew file mode 100644index 000000000..34b9b01bc--- /dev/null+++ b/src/renderer/components/dialogs/hooks/LicenseDialogContextProvider.tsx@@ -0,0 +1,115 @@+/**+ * TagSpaces - universal file and folder organizer+ * Copyright (C) 2017-present TagSpaces UG (haftungsbeschraenkt)+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License (version 3) as+ * published by the Free Software Foundation.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <https://www.gnu.org/licenses/>.+ *+ */++import React, {+ createContext,+ useEffect,+ useMemo,+ useReducer,+ useRef,+} from 'react';+import LoadingLazy from '-/components/LoadingLazy';+import { actions as SettingsActions, isFirstRun } from '-/reducers/settings';+import { AppDispatch } from '-/reducers/app';+import { useDispatch, useSelector } from 'react-redux';+import AppConfig from '-/AppConfig';++type LicenseDialogContextData = {+ openLicenseDialog: () => void;+ closeLicenseDialog: () => void;+};++export const LicenseDialogContext = createContext<LicenseDialogContextData>({+ openLicenseDialog: undefined,+ closeLicenseDialog: undefined,+});++export type LicenseDialogContextProviderProps = {+ children: React.ReactNode;+};++const LicenseDialog = React.lazy(+ () => import(/* webpackChunkName: "LicenseDialog" */ '../LicenseDialog'),+);++export const LicenseDialogContextProvider = ({+ children,+}: LicenseDialogContextProviderProps) => {+ const firstRun: boolean = useSelector(isFirstRun);+ const open = useRef<boolean>(firstRun);+ const dispatch: AppDispatch = useDispatch();++ const [ignored, forceUpdate] = useReducer((x) => x + 1, 0, undefined);++ useEffect(() => {+ if (AppConfig.isElectron) {+ window.electronIO.ipcRenderer.on('cmd', (arg) => {+ if (arg === 'toggle-license-dialog') {+ openDialog();+ }+ });++ return () => {+ if (window.electronIO.ipcRenderer) {+ window.electronIO.ipcRenderer.removeAllListeners('cmd');+ }+ };+ }+ }, []);++ function openDialog() {+ open.current = true;+ forceUpdate();+ }++ function closeDialog() {+ open.current = false;+ forceUpdate();+ }++ function LicenseDialogAsync(props) {+ return (+ <React.Suspense fallback={<LoadingLazy />}>+ <LicenseDialog {...props} />+ </React.Suspense>+ );+ }++ const context = useMemo(() => {+ return {+ openLicenseDialog: openDialog,+ closeLicenseDialog: closeDialog,+ };+ }, []);++ return (+ <LicenseDialogContext.Provider value={context}>+ <LicenseDialogAsync+ open={open.current}+ onClose={(event, reason) => {+ if (reason === 'backdropClick' || reason === 'escapeKeyDown') {+ return true;+ }+ dispatch(SettingsActions.setFirstRun(false));+ closeDialog();+ }}+ />+ {children}+ </LicenseDialogContext.Provider>+ );+};diff --git a/src/renderer/components/dialogs/hooks/LinkDialogContextProvider.tsx b/src/renderer/components/dialogs/hooks/LinkDialogContextProvider.tsxnew file mode 100644index 000000000..79b32dbbf--- /dev/null+++ b/src/renderer/components/dialogs/hooks/LinkDialogContextProvider.tsx@@ -0,0 +1,101 @@+/**+ * TagSpaces - universal file and folder organizer+ * Copyright (C) 2017-present TagSpaces UG (haftungsbeschraenkt)+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License (version 3) as+ * published by the Free Software Foundation.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <https://www.gnu.org/licenses/>.+ *+ */++import React, {+ createContext,+ useEffect,+ useMemo,+ useReducer,+ useRef,+} from 'react';+import LoadingLazy from '-/components/LoadingLazy';+import AppConfig from '-/AppConfig';++type LinkDialogContextData = {+ openLinkDialog: () => void;+ closeLinkDialog: () => void;+};++export const LinkDialogContext = createContext<LinkDialogContextData>({+ openLinkDialog: undefined,+ closeLinkDialog: undefined,+});++export type LinkDialogContextProviderProps = {+ children: React.ReactNode;+};++const LinkDialog = React.lazy(+ () => import(/* webpackChunkName: "OpenLinkDialog" */ '../OpenLinkDialog'),+);++export const LinkDialogContextProvider = ({+ children,+}: LinkDialogContextProviderProps) => {+ const open = useRef<boolean>(false);++ const [ignored, forceUpdate] = useReducer((x) => x + 1, 0, undefined);++ useEffect(() => {+ if (AppConfig.isElectron) {+ window.electronIO.ipcRenderer.on('cmd', (arg) => {+ if (arg === 'toggle-open-link-dialog') {+ openDialog();+ }+ });++ return () => {+ if (window.electronIO.ipcRenderer) {+ window.electronIO.ipcRenderer.removeAllListeners('cmd');+ }+ };+ }+ }, []);++ function openDialog() {+ open.current = true;+ forceUpdate();+ }++ function closeDialog() {+ open.current = false;+ forceUpdate();+ }++ function LinkDialogAsync(props) {+ return (+ <React.Suspense fallback={<LoadingLazy />}>+ <LinkDialog {...props} />+ </React.Suspense>+ );+ }++ const context = useMemo(() => {+ return {+ openLinkDialog: openDialog,+ closeLinkDialog: closeDialog,+ };+ }, []);++ return (+ <LinkDialogContext.Provider value={context}>+ <LinkDialogAsync open={open.current} onClose={closeDialog} />+ {children}+ </LinkDialogContext.Provider>+ );+};diff --git a/src/renderer/components/dialogs/hooks/MoveOrCopyFilesDialogContextProvider.tsx b/src/renderer/components/dialogs/hooks/MoveOrCopyFilesDialogContextProvider.tsxnew file mode 100644index 000000000..ef1e43d00--- /dev/null+++ b/src/renderer/components/dialogs/hooks/MoveOrCopyFilesDialogContextProvider.tsx@@ -0,0 +1,88 @@+/**+ * TagSpaces - universal file and folder organizer+ * Copyright (C) 2017-present TagSpaces UG (haftungsbeschraenkt)+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License (version 3) as+ * published by the Free Software Foundation.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <https://www.gnu.org/licenses/>.+ *+ */++import React, { createContext, useMemo, useReducer, useRef } from 'react';+import LoadingLazy from '-/components/LoadingLazy';++type MoveOrCopyFilesDialogContextData = {+ openMoveOrCopyFilesDialog: (files: Array<File>) => void;+ closeMoveOrCopyFilesDialog: () => void;+};++export const MoveOrCopyFilesDialogContext =+ createContext<MoveOrCopyFilesDialogContextData>({+ openMoveOrCopyFilesDialog: undefined,+ closeMoveOrCopyFilesDialog: undefined,+ });++export type MoveOrCopyFilesDialogContextProviderProps = {+ children: React.ReactNode;+};++const MoveOrCopyFilesDialog = React.lazy(+ () =>+ import(+ /* webpackChunkName: "MoveOrCopyFilesDialog" */ '../MoveOrCopyFilesDialog'+ ),+);++export const MoveOrCopyFilesDialogContextProvider = ({+ children,+}: MoveOrCopyFilesDialogContextProviderProps) => {+ const open = useRef<boolean>(false);+ const files = useRef<Array<File>>(undefined);++ const [ignored, forceUpdate] = useReducer((x) => x + 1, 0, undefined);++ function openDialog(selectedFiles: Array<File>) {+ open.current = true;+ files.current = selectedFiles;+ forceUpdate();+ }++ function closeDialog() {+ open.current = false;+ forceUpdate();+ }++ function MoveOrCopyFilesDialogAsync(props) {+ return (+ <React.Suspense fallback={<LoadingLazy />}>+ <MoveOrCopyFilesDialog {...props} />+ </React.Suspense>+ );+ }++ const context = useMemo(() => {+ return {+ openMoveOrCopyFilesDialog: openDialog,+ closeMoveOrCopyFilesDialog: closeDialog,+ };+ }, []);++ return (+ <MoveOrCopyFilesDialogContext.Provider value={context}>+ <MoveOrCopyFilesDialogAsync+ open={open.current}+ onClose={closeDialog}+ selectedFiles={files.current}+ />+ {children}+ </MoveOrCopyFilesDialogContext.Provider>+ );+};diff --git a/src/renderer/components/dialogs/hooks/NewAudioDialogContextProvider.tsx b/src/renderer/components/dialogs/hooks/NewAudioDialogContextProvider.tsxnew file mode 100644index 000000000..1a7944261--- /dev/null+++ b/src/renderer/components/dialogs/hooks/NewAudioDialogContextProvider.tsx@@ -0,0 +1,78 @@+/**+ * TagSpaces - universal file and folder organizer+ * Copyright (C) 2017-present TagSpaces UG (haftungsbeschraenkt)+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License (version 3) as+ * published by the Free Software Foundation.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <https://www.gnu.org/licenses/>.+ *+ */++import React, { createContext, useMemo, useReducer, useRef } from 'react';+import LoadingLazy from '-/components/LoadingLazy';++type NewAudioDialogContextData = {+ openNewAudioDialog: () => void;+ closeNewAudioDialog: () => void;+};++export const NewAudioDialogContext = createContext<NewAudioDialogContextData>({+ openNewAudioDialog: undefined,+ closeNewAudioDialog: undefined,+});++export type NewAudioDialogContextProviderProps = {+ children: React.ReactNode;+};++const NewAudioDialog = React.lazy(+ () => import(/* webpackChunkName: "NewAudioDialog" */ '../NewAudioDialog'),+);++export const NewAudioDialogContextProvider = ({+ children,+}: NewAudioDialogContextProviderProps) => {+ const open = useRef<boolean>(false);++ const [ignored, forceUpdate] = useReducer((x) => x + 1, 0, undefined);++ function openDialog() {+ open.current = true;+ forceUpdate();+ }++ function closeDialog() {+ open.current = false;+ forceUpdate();+ }++ function NewAudioDialogAsync(props) {+ return (+ <React.Suspense fallback={<LoadingLazy />}>+ <NewAudioDialog {...props} />+ </React.Suspense>+ );+ }++ const context = useMemo(() => {+ return {+ openNewAudioDialog: openDialog,+ closeNewAudioDialog: closeDialog,+ };+ }, []);++ return (+ <NewAudioDialogContext.Provider value={context}>+ <NewAudioDialogAsync open={open.current} onClose={closeDialog} />+ {children}+ </NewAudioDialogContext.Provider>+ );+};diff --git a/src/renderer/components/dialogs/hooks/NewEntryDialogContextProvider.tsx b/src/renderer/components/dialogs/hooks/NewEntryDialogContextProvider.tsxnew file mode 100644index 000000000..7857bb427--- /dev/null+++ b/src/renderer/components/dialogs/hooks/NewEntryDialogContextProvider.tsx@@ -0,0 +1,85 @@+/**+ * TagSpaces - universal file and folder organizer+ * Copyright (C) 2017-present TagSpaces UG (haftungsbeschraenkt)+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License (version 3) as+ * published by the Free Software Foundation.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <https://www.gnu.org/licenses/>.+ *+ */++import React, { createContext, useMemo, useReducer, useRef } from 'react';+import LoadingLazy from '-/components/LoadingLazy';++type NewEntryDialogContextData = {+ openNewEntryDialog: () => void;+ closeNewEntryDialog: () => void;+};++export const NewEntryDialogContext = createContext<NewEntryDialogContextData>({+ openNewEntryDialog: undefined,+ closeNewEntryDialog: undefined,+});++export type NewEntryDialogContextProviderProps = {+ children: React.ReactNode;+};++const NewEntryDialog = React.lazy(+ () => import(/* webpackChunkName: "NewEntryDialog" */ '../NewEntryDialog'),+);++export const NewEntryDialogContextProvider = ({+ children,+}: NewEntryDialogContextProviderProps) => {+ const open = useRef<boolean>(false);++ const [ignored, forceUpdate] = useReducer((x) => x + 1, 0, undefined);++ function openDialog() {+ open.current = true;+ forceUpdate();+ }++ function closeDialog() {+ open.current = false;+ forceUpdate();+ }++ function NewEntryDialogAsync(props) {+ return (+ <React.Suspense fallback={<LoadingLazy />}>+ <NewEntryDialog {...props} />+ </React.Suspense>+ );+ }++ const context = useMemo(() => {+ return {+ openNewEntryDialog: openDialog,+ closeNewEntryDialog: closeDialog,+ };+ }, []);++ return (+ <NewEntryDialogContext.Provider value={context}>+ <NewEntryDialogAsync+ open={open.current}+ onClose={(event, reason) => {+ if (reason !== 'backdropClick') {+ closeDialog();+ }+ }}+ />+ {children}+ </NewEntryDialogContext.Provider>+ );+};diff --git a/src/renderer/components/dialogs/hooks/NewFileDialogContextProvider.tsx b/src/renderer/components/dialogs/hooks/NewFileDialogContextProvider.tsxnew file mode 100644index 000000000..cfe7f7ca6--- /dev/null+++ b/src/renderer/components/dialogs/hooks/NewFileDialogContextProvider.tsx@@ -0,0 +1,109 @@+/**+ * TagSpaces - universal file and folder organizer+ * Copyright (C) 2017-present TagSpaces UG (haftungsbeschraenkt)+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License (version 3) as+ * published by the Free Software Foundation.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <https://www.gnu.org/licenses/>.+ *+ */++import React, {+ createContext,+ useEffect,+ useMemo,+ useReducer,+ useRef,+} from 'react';+import LoadingLazy from '-/components/LoadingLazy';+import AppConfig from '-/AppConfig';+import { actions as SettingsActions } from '-/reducers/settings';++type NewFileDialogContextData = {+ openNewFileDialog: () => void;+ closeNewFileDialog: () => void;+};++export const NewFileDialogContext = createContext<NewFileDialogContextData>({+ openNewFileDialog: undefined,+ closeNewFileDialog: undefined,+});++export type NewFileDialogContextProviderProps = {+ children: React.ReactNode;+};++const NewFileDialog = React.lazy(+ () => import(/* webpackChunkName: "NewFileDialog" */ '../NewFileDialog'),+);++export const NewFileDialogContextProvider = ({+ children,+}: NewFileDialogContextProviderProps) => {+ const open = useRef<boolean>(false);++ const [ignored, forceUpdate] = useReducer((x) => x + 1, 0, undefined);++ useEffect(() => {+ if (AppConfig.isElectron) {+ window.electronIO.ipcRenderer.on('cmd', (arg) => {+ if (arg === 'new-text-file') {+ openDialog();+ }+ });++ return () => {+ if (window.electronIO.ipcRenderer) {+ window.electronIO.ipcRenderer.removeAllListeners('cmd');+ }+ };+ }+ }, []);++ function openDialog() {+ open.current = true;+ forceUpdate();+ }++ function closeDialog() {+ open.current = false;+ forceUpdate();+ }++ function NewFileDialogAsync(props) {+ return (+ <React.Suspense fallback={<LoadingLazy />}>+ <NewFileDialog {...props} />+ </React.Suspense>+ );+ }++ const context = useMemo(() => {+ return {+ openNewFileDialog: openDialog,+ closeNewFileDialog: closeDialog,+ };+ }, []);++ return (+ <NewFileDialogContext.Provider value={context}>+ <NewFileDialogAsync+ open={open.current}+ onClose={(event, reason) => {+ if (reason !== 'backdropClick') {+ closeDialog();+ }+ }}+ />+ {children}+ </NewFileDialogContext.Provider>+ );+};diff --git a/src/renderer/components/dialogs/hooks/OnboardingDialogContextProvider.tsx b/src/renderer/components/dialogs/hooks/OnboardingDialogContextProvider.tsxnew file mode 100644index 000000000..b8c3fa2ca--- /dev/null+++ b/src/renderer/components/dialogs/hooks/OnboardingDialogContextProvider.tsx@@ -0,0 +1,106 @@+/**+ * TagSpaces - universal file and folder organizer+ * Copyright (C) 2017-present TagSpaces UG (haftungsbeschraenkt)+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License (version 3) as+ * published by the Free Software Foundation.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <https://www.gnu.org/licenses/>.+ *+ */++import React, {+ createContext,+ useEffect,+ useMemo,+ useReducer,+ useRef,+} from 'react';+import LoadingLazy from '-/components/LoadingLazy';+import { useSelector } from 'react-redux';+import { isFirstRun } from '-/reducers/settings';+import AppConfig from '-/AppConfig';++type OnboardingDialogContextData = {+ openOnboardingDialog: () => void;+ closeOnboardingDialog: () => void;+};++export const OnboardingDialogContext =+ createContext<OnboardingDialogContextData>({+ openOnboardingDialog: undefined,+ closeOnboardingDialog: undefined,+ });++export type OnboardingDialogContextProviderProps = {+ children: React.ReactNode;+};++const OnboardingDialog = React.lazy(+ () =>+ import(/* webpackChunkName: "OnboardingDialog" */ '../OnboardingDialog'),+);++export const OnboardingDialogContextProvider = ({+ children,+}: OnboardingDialogContextProviderProps) => {+ const firstRun: boolean = useSelector(isFirstRun);+ const open = useRef<boolean>(firstRun);++ const [ignored, forceUpdate] = useReducer((x) => x + 1, 0, undefined);++ useEffect(() => {+ if (AppConfig.isElectron) {+ window.electronIO.ipcRenderer.on('cmd', (arg) => {+ if (arg === 'toggle-onboarding-dialog') {+ openDialog();+ }+ });++ return () => {+ if (window.electronIO.ipcRenderer) {+ window.electronIO.ipcRenderer.removeAllListeners('cmd');+ }+ };+ }+ }, []);++ function openDialog() {+ open.current = true;+ forceUpdate();+ }++ function closeDialog() {+ open.current = false;+ forceUpdate();+ }++ function OnboardingDialogAsync(props) {+ return (+ <React.Suspense fallback={<LoadingLazy />}>+ <OnboardingDialog {...props} />+ </React.Suspense>+ );+ }++ const context = useMemo(() => {+ return {+ openOnboardingDialog: openDialog,+ closeOnboardingDialog: closeDialog,+ };+ }, []);++ return (+ <OnboardingDialogContext.Provider value={context}>+ <OnboardingDialogAsync open={open.current} onClose={closeDialog} />+ {children}+ </OnboardingDialogContext.Provider>+ );+};diff --git a/src/renderer/components/dialogs/hooks/ProTeaserDialogContextProvider.tsx b/src/renderer/components/dialogs/hooks/ProTeaserDialogContextProvider.tsxnew file mode 100644index 000000000..464f4b0b6--- /dev/null+++ b/src/renderer/components/dialogs/hooks/ProTeaserDialogContextProvider.tsx@@ -0,0 +1,101 @@+/**+ * TagSpaces - universal file and folder organizer+ * Copyright (C) 2017-present TagSpaces UG (haftungsbeschraenkt)+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License (version 3) as+ * published by the Free Software Foundation.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <https://www.gnu.org/licenses/>.+ *+ */++import React, { createContext, useMemo, useReducer, useRef } from 'react';+import LoadingLazy from '-/components/LoadingLazy';+import { slidesNames } from '-/content/ProTeaserSlides';++type ProTeaserDialogContextData = {+ openProTeaserDialog: (slidePage?: string) => void;+ closeProTeaserDialog: () => void;+};++export const ProTeaserDialogContext = createContext<ProTeaserDialogContextData>(+ {+ openProTeaserDialog: undefined,+ closeProTeaserDialog: undefined,+ },+);++export type ProTeaserDialogContextProviderProps = {+ children: React.ReactNode;+};++const ProTeaserDialog = React.lazy(+ () => import(/* webpackChunkName: "ProTeaserDialog" */ '../ProTeaserDialog'),+);++export const ProTeaserDialogContextProvider = ({+ children,+}: ProTeaserDialogContextProviderProps) => {+ const open = useRef<boolean>(false);+ const slideIndex = useRef<number>(-1);++ const [ignored, forceUpdate] = useReducer((x) => x + 1, 0, undefined);++ function getProTeaserSlideIndex(slideName: string): number {+ if (!slideName) {+ return -1;+ }+ return slidesNames.findIndex((key) => key === slideName);+ }++ function openDialog(page?: string) {+ let index = -1;+ const proTeaserIndex = getProTeaserSlideIndex(page);+ if (proTeaserIndex && proTeaserIndex > -1) {+ index = proTeaserIndex;+ } else if (slideIndex.current === -1) {+ index = 0;+ }+ slideIndex.current = index;+ open.current = true;+ forceUpdate();+ }++ function closeDialog() {+ open.current = false;+ forceUpdate();+ }++ function ProTeaserDialogAsync(props) {+ return (+ <React.Suspense fallback={<LoadingLazy />}>+ <ProTeaserDialog {...props} />+ </React.Suspense>+ );+ }++ const context = useMemo(() => {+ return {+ openProTeaserDialog: openDialog,+ closeProTeaserDialog: closeDialog,+ };+ }, []);++ return (+ <ProTeaserDialogContext.Provider value={context}>+ <ProTeaserDialogAsync+ open={open.current}+ onClose={closeDialog}+ slideIndex={slideIndex.current}+ />+ {children}+ </ProTeaserDialogContext.Provider>+ );+};diff --git a/src/renderer/components/dialogs/hooks/ProgressDialogContextProvider.tsx b/src/renderer/components/dialogs/hooks/ProgressDialogContextProvider.tsxnew file mode 100644index 000000000..6fc984ac9--- /dev/null+++ b/src/renderer/components/dialogs/hooks/ProgressDialogContextProvider.tsx@@ -0,0 +1,78 @@+/**+ * TagSpaces - universal file and folder organizer+ * Copyright (C) 2017-present TagSpaces UG (haftungsbeschraenkt)+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License (version 3) as+ * published by the Free Software Foundation.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <https://www.gnu.org/licenses/>.+ *+ */++import React, { createContext, useMemo, useReducer, useRef } from 'react';+import LoadingLazy from '-/components/LoadingLazy';++type ProgressDialogContextData = {+ openProgressDialog: () => void;+ closeProgressDialog: () => void;+};++export const ProgressDialogContext = createContext<ProgressDialogContextData>({+ openProgressDialog: undefined,+ closeProgressDialog: undefined,+});++export type ProgressDialogContextProviderProps = {+ children: React.ReactNode;+};++const ProgressDialog = React.lazy(+ () => import(/* webpackChunkName: "ProgressDialog" */ '../ProgressDialog'),+);++export const ProgressDialogContextProvider = ({+ children,+}: ProgressDialogContextProviderProps) => {+ const open = useRef<boolean>(false);++ const [ignored, forceUpdate] = useReducer((x) => x + 1, 0, undefined);++ function openDialog() {+ open.current = true;+ forceUpdate();+ }++ function closeDialog() {+ open.current = false;+ forceUpdate();+ }++ function ProgressDialogAsync(props) {+ return (+ <React.Suspense fallback={<LoadingLazy />}>+ <ProgressDialog {...props} />+ </React.Suspense>+ );+ }++ const context = useMemo(() => {+ return {+ openProgressDialog: openDialog,+ closeProgressDialog: closeDialog,+ };+ }, []);++ return (+ <ProgressDialogContext.Provider value={context}>+ <ProgressDialogAsync open={open.current} onClose={closeDialog} />+ {children}+ </ProgressDialogContext.Provider>+ );+};diff --git a/src/renderer/components/dialogs/hooks/SettingsDialogContextProvider.tsx b/src/renderer/components/dialogs/hooks/SettingsDialogContextProvider.tsxnew file mode 100644index 000000000..f36e64e5e--- /dev/null+++ b/src/renderer/components/dialogs/hooks/SettingsDialogContextProvider.tsx@@ -0,0 +1,104 @@+/**+ * TagSpaces - universal file and folder organizer+ * Copyright (C) 2017-present TagSpaces UG (haftungsbeschraenkt)+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License (version 3) as+ * published by the Free Software Foundation.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <https://www.gnu.org/licenses/>.+ *+ */++import React, {+ createContext,+ useEffect,+ useMemo,+ useReducer,+ useRef,+} from 'react';+import LoadingLazy from '-/components/LoadingLazy';+import AppConfig from '-/AppConfig';++type SettingsDialogContextData = {+ openSettingsDialog: () => void;+ closeSettingsDialog: () => void;+};++export const SettingsDialogContext = createContext<SettingsDialogContextData>({+ openSettingsDialog: undefined,+ closeSettingsDialog: undefined,+});++export type SettingsDialogContextProviderProps = {+ children: React.ReactNode;+};++const SettingsDialog = React.lazy(+ () =>+ import(+ /* webpackChunkName: "SettingsDialog" */ '../settings/SettingsDialog'+ ),+);++export const SettingsDialogContextProvider = ({+ children,+}: SettingsDialogContextProviderProps) => {+ const open = useRef<boolean>(false);++ const [ignored, forceUpdate] = useReducer((x) => x + 1, 0, undefined);++ useEffect(() => {+ if (AppConfig.isElectron) {+ window.electronIO.ipcRenderer.on('cmd', (arg) => {+ if (arg === 'toggle-settings-dialog') {+ openDialog();+ }+ });++ return () => {+ if (window.electronIO.ipcRenderer) {+ window.electronIO.ipcRenderer.removeAllListeners('cmd');+ }+ };+ }+ }, []);++ function openDialog() {+ open.current = true;+ forceUpdate();+ }++ function closeDialog() {+ open.current = false;+ forceUpdate();+ }++ function SettingsDialogAsync(props) {+ return (+ <React.Suspense fallback={<LoadingLazy />}>+ <SettingsDialog {...props} />+ </React.Suspense>+ );+ }++ const context = useMemo(() => {+ return {+ openSettingsDialog: openDialog,+ closeSettingsDialog: closeDialog,+ };+ }, []);++ return (+ <SettingsDialogContext.Provider value={context}>+ <SettingsDialogAsync open={open.current} onClose={closeDialog} />+ {children}+ </SettingsDialogContext.Provider>+ );+};diff --git a/src/renderer/components/dialogs/hooks/ThirdPartyLibsDialogContextProvider.tsx b/src/renderer/components/dialogs/hooks/ThirdPartyLibsDialogContextProvider.tsxnew file mode 100644index 000000000..6505f0faa--- /dev/null+++ b/src/renderer/components/dialogs/hooks/ThirdPartyLibsDialogContextProvider.tsx@@ -0,0 +1,105 @@+/**+ * TagSpaces - universal file and folder organizer+ * Copyright (C) 2017-present TagSpaces UG (haftungsbeschraenkt)+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License (version 3) as+ * published by the Free Software Foundation.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <https://www.gnu.org/licenses/>.+ *+ */++import React, {+ createContext,+ useEffect,+ useMemo,+ useReducer,+ useRef,+} from 'react';+import LoadingLazy from '-/components/LoadingLazy';+import AppConfig from '-/AppConfig';++type ThirdPartyLibsDialogContextData = {+ openThirdPartyLibsDialog: () => void;+ closeThirdPartyLibsDialog: () => void;+};++export const ThirdPartyLibsDialogContext =+ createContext<ThirdPartyLibsDialogContextData>({+ openThirdPartyLibsDialog: undefined,+ closeThirdPartyLibsDialog: undefined,+ });++export type ThirdPartyLibsDialogContextProviderProps = {+ children: React.ReactNode;+};++const ThirdPartyLibsDialog = React.lazy(+ () =>+ import(+ /* webpackChunkName: "ThirdPartyLibsDialog" */ '../ThirdPartyLibsDialog'+ ),+);++export const ThirdPartyLibsDialogContextProvider = ({+ children,+}: ThirdPartyLibsDialogContextProviderProps) => {+ const open = useRef<boolean>(false);++ const [ignored, forceUpdate] = useReducer((x) => x + 1, 0, undefined);++ useEffect(() => {+ if (AppConfig.isElectron) {+ window.electronIO.ipcRenderer.on('cmd', (arg) => {+ if (arg === 'toggle-third-party-libs-dialog') {+ openDialog();+ }+ });++ return () => {+ if (window.electronIO.ipcRenderer) {+ window.electronIO.ipcRenderer.removeAllListeners('cmd');+ }+ };+ }+ }, []);++ function openDialog() {+ open.current = true;+ forceUpdate();+ }++ function closeDialog() {+ open.current = false;+ forceUpdate();+ }++ function ThirdPartyLibsDialogAsync(props) {+ return (+ <React.Suspense fallback={<LoadingLazy />}>+ <ThirdPartyLibsDialog {...props} />+ </React.Suspense>+ );+ }++ const context = useMemo(() => {+ return {+ openThirdPartyLibsDialog: openDialog,+ closeThirdPartyLibsDialog: closeDialog,+ };+ }, []);++ return (+ <ThirdPartyLibsDialogContext.Provider value={context}>+ <ThirdPartyLibsDialogAsync open={open.current} onClose={closeDialog} />+ {children}+ </ThirdPartyLibsDialogContext.Provider>+ );+};diff --git a/src/renderer/components/dialogs/hooks/useAboutDialogContext.tsx b/src/renderer/components/dialogs/hooks/useAboutDialogContext.tsxnew file mode 100644index 000000000..1b2905fff--- /dev/null+++ b/src/renderer/components/dialogs/hooks/useAboutDialogContext.tsx@@ -0,0 +1,5 @@+import { useContext } from 'react';++import { AboutDialogContext } from '-/components/dialogs/hooks/AboutDialogContextProvider';++export const useAboutDialogContext = () => useContext(AboutDialogContext);diff --git a/src/renderer/components/dialogs/hooks/useCreateDirectoryDialogContext.tsx b/src/renderer/components/dialogs/hooks/useCreateDirectoryDialogContext.tsxnew file mode 100644index 000000000..0c8824bab--- /dev/null+++ b/src/renderer/components/dialogs/hooks/useCreateDirectoryDialogContext.tsx@@ -0,0 +1,6 @@+import { useContext } from 'react';++import { CreateDirectoryDialogContext } from '-/components/dialogs/hooks/CreateDirectoryDialogContextProvider';++export const useCreateDirectoryDialogContext = () =>+ useContext(CreateDirectoryDialogContext);diff --git a/src/renderer/components/dialogs/hooks/useCreateEditLocationDialogContext.tsx b/src/renderer/components/dialogs/hooks/useCreateEditLocationDialogContext.tsxnew file mode 100644index 000000000..8bede743e--- /dev/null+++ b/src/renderer/components/dialogs/hooks/useCreateEditLocationDialogContext.tsx@@ -0,0 +1,6 @@+import { useContext } from 'react';++import { CreateEditLocationDialogContext } from '-/components/dialogs/hooks/CreateEditLocationDialogContextProvider';++export const useCreateEditLocationDialogContext = () =>+ useContext(CreateEditLocationDialogContext);diff --git a/src/renderer/components/dialogs/hooks/useDeleteMultipleEntriesDialogContext.tsx b/src/renderer/components/dialogs/hooks/useDeleteMultipleEntriesDialogContext.tsxnew file mode 100644index 000000000..2f914a8cc--- /dev/null+++ b/src/renderer/components/dialogs/hooks/useDeleteMultipleEntriesDialogContext.tsx@@ -0,0 +1,6 @@+import { useContext } from 'react';++import { DeleteMultipleEntriesDialogContext } from '-/components/dialogs/hooks/DeleteMultipleEntriesDialogContextProvider';++export const useDeleteMultipleEntriesDialogContext = () =>+ useContext(DeleteMultipleEntriesDialogContext);diff --git a/src/renderer/components/dialogs/hooks/useKeyboardDialogContext.tsx b/src/renderer/components/dialogs/hooks/useKeyboardDialogContext.tsxnew file mode 100644index 000000000..5f6c1e1a0--- /dev/null+++ b/src/renderer/components/dialogs/hooks/useKeyboardDialogContext.tsx@@ -0,0 +1,5 @@+import { useContext } from 'react';++import { KeyboardDialogContext } from '-/components/dialogs/hooks/KeyboardDialogContextProvider';++export const useKeyboardDialogContext = () => useContext(KeyboardDialogContext);diff --git a/src/renderer/components/dialogs/hooks/useLicenseDialogContext.tsx b/src/renderer/components/dialogs/hooks/useLicenseDialogContext.tsxnew file mode 100644index 000000000..0f19a0aaf--- /dev/null+++ b/src/renderer/components/dialogs/hooks/useLicenseDialogContext.tsx@@ -0,0 +1,5 @@+import { useContext } from 'react';++import { LicenseDialogContext } from '-/components/dialogs/hooks/LicenseDialogContextProvider';++export const useLicenseDialogContext = () => useContext(LicenseDialogContext);diff --git a/src/renderer/components/dialogs/hooks/useLinkDialogContext.tsx b/src/renderer/components/dialogs/hooks/useLinkDialogContext.tsxnew file mode 100644index 000000000..213a17326--- /dev/null+++ b/src/renderer/components/dialogs/hooks/useLinkDialogContext.tsx@@ -0,0 +1,5 @@+import { useContext } from 'react';++import { LinkDialogContext } from '-/components/dialogs/hooks/LinkDialogContextProvider';++export const useLinkDialogContext = () => useContext(LinkDialogContext);diff --git a/src/renderer/components/dialogs/hooks/useMoveOrCopyFilesDialogContext.tsx b/src/renderer/components/dialogs/hooks/useMoveOrCopyFilesDialogContext.tsxnew file mode 100644index 000000000..cbaf26678--- /dev/null+++ b/src/renderer/components/dialogs/hooks/useMoveOrCopyFilesDialogContext.tsx@@ -0,0 +1,6 @@+import { useContext } from 'react';++import { MoveOrCopyFilesDialogContext } from '-/components/dialogs/hooks/MoveOrCopyFilesDialogContextProvider';++export const useMoveOrCopyFilesDialogContext = () =>+ useContext(MoveOrCopyFilesDialogContext);diff --git a/src/renderer/components/dialogs/hooks/useNewAudioDialogContext.tsx b/src/renderer/components/dialogs/hooks/useNewAudioDialogContext.tsxnew file mode 100644index 000000000..ef7953522--- /dev/null+++ b/src/renderer/components/dialogs/hooks/useNewAudioDialogContext.tsx@@ -0,0 +1,5 @@+import { useContext } from 'react';++import { NewAudioDialogContext } from '-/components/dialogs/hooks/NewAudioDialogContextProvider';++export const useNewAudioDialogContext = () => useContext(NewAudioDialogContext);diff --git a/src/renderer/components/dialogs/hooks/useNewEntryDialogContext.tsx b/src/renderer/components/dialogs/hooks/useNewEntryDialogContext.tsxnew file mode 100644index 000000000..2f59f7bc4--- /dev/null+++ b/src/renderer/components/dialogs/hooks/useNewEntryDialogContext.tsx@@ -0,0 +1,5 @@+import { useContext } from 'react';++import { NewEntryDialogContext } from '-/components/dialogs/hooks/NewEntryDialogContextProvider';++export const useNewEntryDialogContext = () => useContext(NewEntryDialogContext);diff --git a/src/renderer/components/dialogs/hooks/useNewFileDialogContext.tsx b/src/renderer/components/dialogs/hooks/useNewFileDialogContext.tsxnew file mode 100644index 000000000..2bc975acb--- /dev/null+++ b/src/renderer/components/dialogs/hooks/useNewFileDialogContext.tsx@@ -0,0 +1,5 @@+import { useContext } from 'react';++import { NewFileDialogContext } from '-/components/dialogs/hooks/NewFileDialogContextProvider';++export const useNewFileDialogContext = () => useContext(NewFileDialogContext);diff --git a/src/renderer/components/dialogs/hooks/useOnboardingDialogContext.tsx b/src/renderer/components/dialogs/hooks/useOnboardingDialogContext.tsxnew file mode 100644index 000000000..ba2bc717f--- /dev/null+++ b/src/renderer/components/dialogs/hooks/useOnboardingDialogContext.tsx@@ -0,0 +1,6 @@+import { useContext } from 'react';++import { OnboardingDialogContext } from '-/components/dialogs/hooks/OnboardingDialogContextProvider';++export const useOnboardingDialogContext = () =>+ useContext(OnboardingDialogContext);diff --git a/src/renderer/components/dialogs/hooks/useProTeaserDialogContext.tsx b/src/renderer/components/dialogs/hooks/useProTeaserDialogContext.tsxnew file mode 100644index 000000000..a2413d66b--- /dev/null+++ b/src/renderer/components/dialogs/hooks/useProTeaserDialogContext.tsx@@ -0,0 +1,6 @@+import { useContext } from 'react';++import { ProTeaserDialogContext } from '-/components/dialogs/hooks/ProTeaserDialogContextProvider';++export const useProTeaserDialogContext = () =>+ useContext(ProTeaserDialogContext);diff --git a/src/renderer/components/dialogs/hooks/useProgressDialogContext.tsx b/src/renderer/components/dialogs/hooks/useProgressDialogContext.tsxnew file mode 100644index 000000000..395e99d81--- /dev/null+++ b/src/renderer/components/dialogs/hooks/useProgressDialogContext.tsx@@ -0,0 +1,5 @@+import { useContext } from 'react';++import { ProgressDialogContext } from '-/components/dialogs/hooks/ProgressDialogContextProvider';++export const useProgressDialogContext = () => useContext(ProgressDialogContext);diff --git a/src/renderer/components/dialogs/hooks/useSettingsDialogContext.tsx b/src/renderer/components/dialogs/hooks/useSettingsDialogContext.tsxnew file mode 100644index 000000000..f99ce279d--- /dev/null+++ b/src/renderer/components/dialogs/hooks/useSettingsDialogContext.tsx@@ -0,0 +1,5 @@+import { useContext } from 'react';++import { SettingsDialogContext } from '-/components/dialogs/hooks/SettingsDialogContextProvider';++export const useSettingsDialogContext = () => useContext(SettingsDialogContext);diff --git a/src/renderer/components/dialogs/hooks/useThirdPartyLibsDialogContext.tsx b/src/renderer/components/dialogs/hooks/useThirdPartyLibsDialogContext.tsxnew file mode 100644index 000000000..c158c4563--- /dev/null+++ b/src/renderer/components/dialogs/hooks/useThirdPartyLibsDialogContext.tsx@@ -0,0 +1,6 @@+import { useContext } from 'react';++import { ThirdPartyLibsDialogContext } from '-/components/dialogs/hooks/ThirdPartyLibsDialogContextProvider';++export const useThirdPartyLibsDialogContext = () =>+ useContext(ThirdPartyLibsDialogContext);diff --git a/src/renderer/components/menus/DirectoryMenu.tsx b/src/renderer/components/menus/DirectoryMenu.tsxindex e8e7de53f..9a745b5c9 100644--- a/src/renderer/components/menus/DirectoryMenu.tsx+++ b/src/renderer/components/menus/DirectoryMenu.tsx@@ -54,6 +54,12 @@ import { generateClipboardLink } from '-/utils/dom';import { useEditedEntryContext } from '-/hooks/useEditedEntryContext';import { TS } from '-/tagspaces.namespace';import { useIOActionsContext } from '-/hooks/useIOActionsContext';+import { useCreateDirectoryDialogContext } from '-/components/dialogs/hooks/useCreateDirectoryDialogContext';+import { useProgressDialogContext } from '-/components/dialogs/hooks/useProgressDialogContext';+import { useNewFileDialogContext } from '-/components/dialogs/hooks/useNewFileDialogContext';+import { useNewAudioDialogContext } from '-/components/dialogs/hooks/useNewAudioDialogContext';+import { useProTeaserDialogContext } from '-/components/dialogs/hooks/useProTeaserDialogContext';+import { useDeleteMultipleEntriesDialogContext } from '-/components/dialogs/hooks/useDeleteMultipleEntriesDialogContext';interface Props {open: boolean;@@ -75,10 +81,13 @@ function DirectoryMenu(props: Props) {const { openEntry } = useOpenedEntryContext();const { selectedEntries, setSelectedEntries } = useSelectedEntriesContext();const { addTags } = useTaggingActionsContext();+ const { openProgressDialog } = useProgressDialogContext();+ const { openNewFileDialog } = useNewFileDialogContext();const { currentLocation, readOnlyMode, getLocationPath, findLocation } =useCurrentLocationContext();const { setThumbnailImageChange } = useIOActionsContext();const { showNotification } = useNotificationContext();+ const { openCreateDirectoryDialog } = useCreateDirectoryDialogContext();const {openDirectory,currentDirectoryPath,@@ -89,6 +98,10 @@ function DirectoryMenu(props: Props) {const { generateThumbnails } = useThumbGenerationContext();const { copyFilePromise, renameFilePromise } = usePlatformFacadeContext();const { setReflectActions } = useEditedEntryContext();+ const { openNewAudioDialog } = useNewAudioDialogContext();+ const { openProTeaserDialog } = useProTeaserDialogContext();+ const { openDeleteMultipleEntriesDialog } =+ useDeleteMultipleEntriesDialogContext();const fileUploadContainerRef = useRef<FileUploadContainerRef>(null);const {open,@@ -103,28 +116,6 @@ function DirectoryMenu(props: Props) {perspectiveMode,} = props;const directoryPath = props.directoryPath || currentDirectoryPath;- //const locations: Array<CommonLocation> = useSelector(getLocations);- const dispatch: AppDispatch = useDispatch();-- const toggleCreateDirectoryDialog = () => {- dispatch(AppActions.toggleCreateDirectoryDialog());- };-- const toggleNewFileDialog = () => {- dispatch(AppActions.toggleNewFileDialog());- };-- const toggleProgressDialog = () => {- dispatch(AppActions.toggleProgressDialog());- };-- const toggleDeleteMultipleEntriesDialog = () => {- dispatch(AppActions.toggleDeleteMultipleEntriesDialog());- };-- const toggleProTeaser = (slidePage) => {- dispatch(AppActions.toggleProTeaser(slidePage));- };function generateFolderLink(): Promise<any> {let locationID = currentLocation.uuid;@@ -187,11 +178,11 @@ function DirectoryMenu(props: Props) {setManualDirectoryPerspective(perspectiveId);}} else if (perspectiveId === PerspectiveIDs.GALLERY) {- toggleProTeaser(PerspectiveIDs.GALLERY);+ openProTeaserDialog(PerspectiveIDs.GALLERY);} else if (perspectiveId === PerspectiveIDs.MAPIQUE) {- toggleProTeaser(PerspectiveIDs.MAPIQUE);+ openProTeaserDialog(PerspectiveIDs.MAPIQUE);} else if (perspectiveId === PerspectiveIDs.KANBAN) {- toggleProTeaser(PerspectiveIDs.KANBAN);+ openProTeaserDialog(PerspectiveIDs.KANBAN);}}@@ -199,15 +190,15 @@ function DirectoryMenu(props: Props) {if (!selectedEntries.some((entry) => entry.path === directoryPath)) {setSelectedEntries([currentLocation.toFsEntry(directoryPath, false)]);}- toggleDeleteMultipleEntriesDialog();+ openDeleteMultipleEntriesDialog();}function createNewFile() {- toggleNewFileDialog();+ openNewFileDialog();}function createNewAudio() {- dispatch(AppActions.toggleNewAudioDialog());+ openNewAudioDialog();}function showInFileManager() {@@ -235,7 +226,7 @@ Do you want to continue?`)) {return false;}- toggleProgressDialog();+ openProgressDialog();const entryCallback = (entry) => {readMacOSTags(entry.path)@@ -255,7 +246,7 @@ Do you want to continue?`)entryCallback,).then(() => {- toggleProgressDialog();+ openProgressDialog();console.log('Import tags succeeded ' + directoryPath);showNotification('Tags from ' + directoryPath + ' are imported successfully.',@@ -266,7 +257,7 @@ Do you want to continue?`)}).catch((err) => {console.log('Error importing tags: ' + err);- toggleProgressDialog();+ openProgressDialog();});} else {showNotification(@@ -427,7 +418,7 @@ Do you want to continue?`)showInFileManager,createNewFile,createNewAudio,- toggleCreateDirectoryDialog,+ openCreateDirectoryDialog,addExistingFile,setFolderThumbnail,copySharingLink,diff --git a/src/renderer/components/menus/EntryTagMenu.tsx b/src/renderer/components/menus/EntryTagMenu.tsxindex 4cd4c0835..29b057177 100644--- a/src/renderer/components/menus/EntryTagMenu.tsx+++ b/src/renderer/components/menus/EntryTagMenu.tsx@@ -28,12 +28,10 @@ import Menu from '@mui/material/Menu';import MenuItem from '@mui/material/MenuItem';import ConfirmDialog from '../dialogs/ConfirmDialog';import { getMaxSearchResults } from '-/reducers/settings';-import { actions as AppActions, AppDispatch } from '-/reducers/app';import { TS } from '-/tagspaces.namespace';import { useTranslation } from 'react-i18next';import { useTaggingActionsContext } from '-/hooks/useTaggingActionsContext';import { useCurrentLocationContext } from '-/hooks/useCurrentLocationContext';-import { useLocationIndexContext } from '-/hooks/useLocationIndexContext';import { useDirectoryContentContext } from '-/hooks/useDirectoryContentContext';interface Props {@@ -59,21 +57,16 @@ function EntryTagMenu(props: Props) {const { t } = useTranslation();const { setSearchQuery } = useDirectoryContentContext();- const { removeTags } = useTaggingActionsContext();+ const { removeTags, openEditEntryTagDialog } = useTaggingActionsContext();const { readOnlyMode } = useCurrentLocationContext();const [isDeleteTagDialogOpened, setIsDeleteTagDialogOpened] = useState(false);- const dispatch: AppDispatch = useDispatch();const maxSearchResults: number = useSelector(getMaxSearchResults);- const toggleEditTagDialog = (tag) => {- dispatch(AppActions.toggleEditTagDialog(tag));- };-function showEditTagDialog() {onClose();const tag = selectedTag;tag.path = currentEntryPath;- toggleEditTagDialog(tag);+ openEditEntryTagDialog(tag);}function showDeleteTagDialog() {diff --git a/src/renderer/components/menus/FileMenu.tsx b/src/renderer/components/menus/FileMenu.tsxindex 6acbe4281..e2b0b3508 100644--- a/src/renderer/components/menus/FileMenu.tsx+++ b/src/renderer/components/menus/FileMenu.tsx@@ -66,6 +66,7 @@ import { useIOActionsContext } from '-/hooks/useIOActionsContext';import MenuKeyBinding from '-/components/menus/MenuKeyBinding';import { TS } from '-/tagspaces.namespace';import { generateClipboardLink } from '-/utils/dom';+import { useDeleteMultipleEntriesDialogContext } from '-/components/dialogs/hooks/useDeleteMultipleEntriesDialogContext';interface Props {anchorEl: Element;@@ -73,7 +74,6 @@ interface Props {mouseY?: number;open: boolean;onClose: () => void;- openDeleteFileDialog: () => void;openRenameFileDialog: () => void;openMoveCopyFilesDialog: () => void;openShareFilesDialog?: () => void;@@ -86,7 +86,6 @@ interface Props {function FileMenu(props: Props) {const {- openDeleteFileDialog,openRenameFileDialog,openMoveCopyFilesDialog,openShareFilesDialog,@@ -104,6 +103,8 @@ function FileMenu(props: Props) {const keyBindings = useSelector(getKeyBindingObject);const { t } = useTranslation();const { selectedEntries } = useSelectedEntriesContext();+ const { openDeleteMultipleEntriesDialog } =+ useDeleteMultipleEntriesDialogContext();const {setBackgroundImageChange,setThumbnailImageChange,@@ -157,7 +158,7 @@ function FileMenu(props: Props) {function showDeleteFileDialog() {onClose();- openDeleteFileDialog();+ openDeleteMultipleEntriesDialog();}function showRenameFileDialog() {diff --git a/src/renderer/components/menus/LocationContextMenu.tsx b/src/renderer/components/menus/LocationContextMenu.tsxindex d84f45f38..a2f6f71fa 100644--- a/src/renderer/components/menus/LocationContextMenu.tsx+++ b/src/renderer/components/menus/LocationContextMenu.tsx@@ -41,16 +41,16 @@ import { useTranslation } from 'react-i18next';import { useCurrentLocationContext } from '-/hooks/useCurrentLocationContext';import { useLocationIndexContext } from '-/hooks/useLocationIndexContext';import { createNewInstance, openDirectoryMessage } from '-/services/utils-io';+import { useCreateEditLocationDialogContext } from '-/components/dialogs/hooks/useCreateEditLocationDialogContext';interface Props {- setEditLocationDialogOpened: (open: boolean) => void;+ //setEditLocationDialogOpened: (open: boolean) => void;setDeleteLocationDialogOpened: (open: boolean) => void;//closeLocationTree: () => void;}function LocationContextMenu(props: Props) {const {- setEditLocationDialogOpened,setDeleteLocationDialogOpened,//closeLocationTree} = props;@@ -66,6 +66,7 @@ function LocationContextMenu(props: Props) {getLocationPath,} = useCurrentLocationContext();const { createLocationIndex } = useLocationIndexContext();+ const { openCreateEditLocationDialog } = useCreateEditLocationDialogContext();const dispatch: AppDispatch = useDispatch();const moveLocationUp = (locationId) => {@@ -83,7 +84,7 @@ function LocationContextMenu(props: Props) {const showEditLocationDialog = () => {setLocationDirectoryContextMenuAnchorEl(null);- setEditLocationDialogOpened(true);+ openCreateEditLocationDialog();};const duplicateLocation = () => {diff --git a/src/renderer/components/menus/LocationManagerMenu.tsx b/src/renderer/components/menus/LocationManagerMenu.tsxindex 2bf3d062c..47a3c26fc 100644--- a/src/renderer/components/menus/LocationManagerMenu.tsx+++ b/src/renderer/components/menus/LocationManagerMenu.tsx@@ -41,13 +41,13 @@ import { openURLExternally } from '-/services/utils-io';import { useTranslation } from 'react-i18next';import { useCurrentLocationContext } from '-/hooks/useCurrentLocationContext';import { useLocationIndexContext } from '-/hooks/useLocationIndexContext';+import { useLinkDialogContext } from '-/components/dialogs/hooks/useLinkDialogContext';interface Props {classes: any;exportLocations: () => void;importLocations: () => void;showCreateLocationDialog: () => void;- toggleOpenLinkDialog: () => void;}function LocationManagerMenu(props: Props) {@@ -56,12 +56,12 @@ function LocationManagerMenu(props: Props) {exportLocations,importLocations,showCreateLocationDialog,- toggleOpenLinkDialog,} = props;const { t } = useTranslation();const { createLocationsIndexes } = useLocationIndexContext();const { closeAllLocations } = useCurrentLocationContext();+ const { openLinkDialog } = useLinkDialogContext();const [locationManagerMenuAnchorEl, setLocationManagerMenuAnchorEl] =useState<null | HTMLElement>(null);const menuItems = [];@@ -89,7 +89,7 @@ function LocationManagerMenu(props: Props) {data-tid="locationManagerMenuOpenLink"onClick={() => {setLocationManagerMenuAnchorEl(null);- toggleOpenLinkDialog();+ openLinkDialog();}}><ListItemIcon>diff --git a/src/renderer/containers/DialogsRoot.tsx b/src/renderer/containers/DialogsRoot.tsxindex 56d426e0c..415186b99 100644--- a/src/renderer/containers/DialogsRoot.tsx+++ b/src/renderer/containers/DialogsRoot.tsx@@ -19,6 +19,22 @@import React from 'react';import { FileUploadDialogContextProvider } from '-/components/dialogs/hooks/FileUploadDialogContextProvider';import { EntryExistDialogContextProvider } from '-/components/dialogs/hooks/EntryExistDialogContextProvider';+import { CreateEditLocationDialogContextProvider } from '-/components/dialogs/hooks/CreateEditLocationDialogContextProvider';+import { MoveOrCopyFilesDialogContextProvider } from '-/components/dialogs/hooks/MoveOrCopyFilesDialogContextProvider';+import { CreateDirectoryDialogContextProvider } from '-/components/dialogs/hooks/CreateDirectoryDialogContextProvider';+import { ProgressDialogContextProvider } from '-/components/dialogs/hooks/ProgressDialogContextProvider';+import { NewEntryDialogContextProvider } from '-/components/dialogs/hooks/NewEntryDialogContextProvider';+import { NewFileDialogContextProvider } from '-/components/dialogs/hooks/NewFileDialogContextProvider';+import { NewAudioDialogContextProvider } from '-/components/dialogs/hooks/NewAudioDialogContextProvider';+import { LicenseDialogContextProvider } from '-/components/dialogs/hooks/LicenseDialogContextProvider';+import { ThirdPartyLibsDialogContextProvider } from '-/components/dialogs/hooks/ThirdPartyLibsDialogContextProvider';+import { AboutDialogContextProvider } from '-/components/dialogs/hooks/AboutDialogContextProvider';+import { OnboardingDialogContextProvider } from '-/components/dialogs/hooks/OnboardingDialogContextProvider';+import { KeyboardDialogContextProvider } from '-/components/dialogs/hooks/KeyboardDialogContextProvider';+import { LinkDialogContextProvider } from '-/components/dialogs/hooks/LinkDialogContextProvider';+import { ProTeaserDialogContextProvider } from '-/components/dialogs/hooks/ProTeaserDialogContextProvider';+import { SettingsDialogContextProvider } from '-/components/dialogs/hooks/SettingsDialogContextProvider';+import { DeleteMultipleEntriesDialogContextProvider } from '-/components/dialogs/hooks/DeleteMultipleEntriesDialogContextProvider';export type DialogsRootProps = {children: React.ReactNode;@@ -27,9 +43,41 @@ export type DialogsRootProps = {function DialogsRoot({ children }: DialogsRootProps) {return (<EntryExistDialogContextProvider>- <FileUploadDialogContextProvider>- {children}- </FileUploadDialogContextProvider>+ <DeleteMultipleEntriesDialogContextProvider>+ <FileUploadDialogContextProvider>+ <CreateEditLocationDialogContextProvider>+ <MoveOrCopyFilesDialogContextProvider>+ <CreateDirectoryDialogContextProvider>+ <ProgressDialogContextProvider>+ <NewEntryDialogContextProvider>+ <NewFileDialogContextProvider>+ <NewAudioDialogContextProvider>+ <LicenseDialogContextProvider>+ <ThirdPartyLibsDialogContextProvider>+ <AboutDialogContextProvider>+ <OnboardingDialogContextProvider>+ <KeyboardDialogContextProvider>+ <LinkDialogContextProvider>+ <ProTeaserDialogContextProvider>+ <SettingsDialogContextProvider>+ {children}+ </SettingsDialogContextProvider>+ </ProTeaserDialogContextProvider>+ </LinkDialogContextProvider>+ </KeyboardDialogContextProvider>+ </OnboardingDialogContextProvider>+ </AboutDialogContextProvider>+ </ThirdPartyLibsDialogContextProvider>+ </LicenseDialogContextProvider>+ </NewAudioDialogContextProvider>+ </NewFileDialogContextProvider>+ </NewEntryDialogContextProvider>+ </ProgressDialogContextProvider>+ </CreateDirectoryDialogContextProvider>+ </MoveOrCopyFilesDialogContextProvider>+ </CreateEditLocationDialogContextProvider>+ </FileUploadDialogContextProvider>+ </DeleteMultipleEntriesDialogContextProvider></EntryExistDialogContextProvider>);}diff --git a/src/renderer/containers/MainPage.tsx b/src/renderer/containers/MainPage.tsxindex fbd509edc..33283d913 100644--- a/src/renderer/containers/MainPage.tsx+++ b/src/renderer/containers/MainPage.tsx@@ -19,75 +19,33 @@import React, { useEffect, useReducer, useRef, useState } from 'react';import clsx from 'clsx';import { bindActionCreators } from 'redux';-import { connect } from 'react-redux';+import { connect, useSelector } from 'react-redux';import SwipeableDrawer from '@mui/material/SwipeableDrawer';import Drawer from '@mui/material/Drawer';import { HotKeys } from 'react-hotkeys';import { NativeTypes } from 'react-dnd-html5-backend';-import { Progress } from 'aws-sdk/clients/s3';-import { CognitoUserInterface } from '@aws-amplify/ui-components';import { Split } from 'ts-react-splitter';import { buffer } from '@tagspaces/tagspaces-common/misc';import AppConfig from '-/AppConfig';import MobileNavigation from '../components/MobileNavigation';import FolderContainer from '../components/FolderContainer';import EntryContainer from '../components/EntryContainer';-import SettingsDialog from '../components/dialogs/settings/SettingsDialog';-import CreateDirectoryDialog from '../components/dialogs/CreateDirectoryDialog';-import NewEntryDialog from '../components/dialogs/NewEntryDialog';import {getDesktopMode,getKeyBindingObject,getMainVerticalSplitSize,actions as SettingsActions,} from '../reducers/settings';-import {- actions as AppActions,- isAboutDialogOpened,- isOnboardingDialogOpened,- isKeysDialogOpened,- isLicenseDialogOpened,- isThirdPartyLibsDialogOpened,- isLocationManagerPanelOpened,- isTagLibraryPanelOpened,- isSearchPanelOpened,- isHelpFeedbackPanelOpened,- isEditTagDialogOpened,- isCreateDirectoryOpened,- isNewEntryDialogOpened,- isNewFileDialogOpened,- isSettingsDialogOpened,- isOpenLinkDialogOpened,- isProgressOpened,- isDeleteMultipleEntriesDialogOpened,- isImportKanBanDialogOpened,- currentUser,- isLocationDialogOpened,- isProTeaserVisible,- isTruncatedConfirmDialogOpened,- isNewAudioDialogOpened,-} from '../reducers/app';import TargetFileBox from '../components/TargetFileBox';-import LoadingLazy from '../components/LoadingLazy';import CustomDragLayer from '-/components/CustomDragLayer';-import ProgressDialog from '-/components/dialogs/ProgressDialog';import useEventListener from '-/utils/useEventListener';-import ConfirmDialog from '-/components/dialogs/ConfirmDialog';-import { TS } from '-/tagspaces.namespace';import PageNotification from '-/containers/PageNotification';-import MoveOrCopyFilesDialog from '-/components/dialogs/MoveOrCopyFilesDialog';-import { Pro } from '-/pro';-import NewFileDialog from '-/components/dialogs/NewFileDialog';-import IsTruncatedConfirmDialog from '-/components/dialogs/IsTruncatedConfirmDialog';import { styled, useTheme } from '@mui/material/styles';-import { useTranslation } from 'react-i18next';-import { DescriptionContextProvider } from '-/hooks/DescriptionContextProvider';+import { FilePropertiesContextProvider } from '-/hooks/FilePropertiesContextProvider';import { useOpenedEntryContext } from '-/hooks/useOpenedEntryContext';import { useDirectoryContentContext } from '-/hooks/useDirectoryContentContext';-import { useSelectedEntriesContext } from '-/hooks/useSelectedEntriesContext';-import { useIOActionsContext } from '-/hooks/useIOActionsContext';-import { useNotificationContext } from '-/hooks/useNotificationContext';-import NewAudioDialog from '-/components/dialogs/NewAudioDialog';+import { usePanelsContext } from '-/hooks/usePanelsContext';+import { useUserContext } from '-/hooks/useUserContext';const drawerWidth = 320;const body = document.getElementsByTagName('body')[0];@@ -96,8 +54,6 @@ const bufferedLeftSplitResize = buffer({id: 'buffered-leftsplit-resize',});-const KanBanImportDialog = Pro && Pro.UI ? Pro.UI.KanBanImportDialog : false;-const PREFIX = 'MainPage';const classes = {@@ -129,198 +85,16 @@ const Root = styled('div')(({ theme }) => ({}));interface Props {- //isFirstRun: boolean;- setFirstRun: (isFirstRun: boolean) => void;- isDesktopMode: boolean;- isSettingsDialogOpened: boolean;- isNewEntryDialogOpened: boolean;- isNewFileDialogOpened: boolean;- isNewAudioDialogOpened: boolean;- isCreateDirectoryOpened: any;- toggleCreateDirectoryDialog: () => void;- isAboutDialogOpened: boolean;- isLocationDialogOpened: boolean;- isKeysDialogOpened: boolean;- isLicenseDialogOpened: boolean;- isThirdPartyLibsDialogOpened: boolean;- isOnboardingDialogOpened: boolean;- //isUploadProgressDialogOpened: string | undefined;- isTruncatedConfirmDialogOpened: boolean;- isProgressDialogOpened: boolean;- isProTeaserVisible: boolean;- //toggleUploadDialog: () => void;- toggleOpenLinkDialog: () => void;- toggleProgressDialog: () => void;- resetProgress: () => void;- isEditTagDialogOpened: boolean;- keyBindings: any;- toggleEditTagDialog: (tag: TS.Tag) => void;- toggleNewEntryDialog: () => void; // needed by electron-menus- toggleNewFileDialog: () => void; // needed by electron-menus- toggleNewAudioDialog: () => void; // needed by electron-menus- toggleSettingsDialog: () => void; // needed by electron-menus- toggleKeysDialog: () => void; // needed by electron-menus- toggleLicenseDialog: () => void; // needed by electron-menus- toggleImportKanBanDialog: () => void;- toggleThirdPartyLibsDialog: () => void; // neede by electron-menus- toggleAboutDialog: () => void; // needed by electron-menus- toggleLocationDialog: () => void; // needed by electron-menus- toggleOnboardingDialog: () => void; // needed by electron-menus- toggleProTeaser: () => void; // needed by electron-menus- // setLastSelectedEntry: (path: string) => void; // needed by electron-menus- // setSelectedEntries: (selectedEntries: Array<Object>) => void; // needed by electron-menus- openLocationManagerPanel: () => void;- openTagLibraryPanel: () => void;- // openSearchPanel: () => void;- openHelpFeedbackPanel: () => void;- // closeAllVerticalPanels: () => void;- //leftSplitSize: number;- mainSplitSize: any;toggleShowUnixHiddenEntries: () => void;- toggleTruncatedConfirmDialog: () => void;setMainVerticalSplitSize: (splitSize: string) => void;- isLocationManagerPanelOpened: boolean;- isOpenLinkDialogOpened: boolean;+ /*isLocationManagerPanelOpened: boolean;isTagLibraryPanelOpened: boolean;isSearchPanelOpened: boolean;- isHelpFeedbackPanelOpened: boolean;- onUploadProgress: (progress: Progress, response: any) => void;- isDeleteMultipleEntriesDialogOpened: boolean;- isImportKanBanDialogOpened: boolean;- toggleDeleteMultipleEntriesDialog: () => void;- user: CognitoUserInterface;-}--const CreateEditLocationDialog = React.lazy(- () =>- import(- /* webpackChunkName: "CreateEditLocationDialog" */ '../components/dialogs/CreateEditLocationDialog'- ),-);-function CreateEditLocationDialogAsync(props) {- return (- <React.Suspense fallback={<LoadingLazy />}>- <CreateEditLocationDialog {...props} />- </React.Suspense>- );-}--const AboutDialog = React.lazy(- () =>- import(- /* webpackChunkName: "AboutDialog" */ '../components/dialogs/AboutDialog'- ),-);-function AboutDialogAsync(props) {- return (- <React.Suspense fallback={<LoadingLazy />}>- <AboutDialog {...props} />- </React.Suspense>- );-}--const LicenseDialog = React.lazy(- () =>- import(- /* webpackChunkName: "LicenseDialog" */ '../components/dialogs/LicenseDialog'- ),-);-function LicenseDialogAsync(props) {- return (- <React.Suspense fallback={<LoadingLazy />}>- <LicenseDialog {...props} />- </React.Suspense>- );-}--const KeyboardDialog = React.lazy(- () =>- import(- /* webpackChunkName: "KeyboardDialog" */ '../components/dialogs/KeyboardDialog'- ),-);-function KeyboardDialogAsync(props) {- return (- <React.Suspense fallback={<LoadingLazy />}>- <KeyboardDialog {...props} />- </React.Suspense>- );-}--const ThirdPartyLibsDialog = React.lazy(- () =>- import(- /* webpackChunkName: "ThirdPartyLibsDialog" */ '../components/dialogs/ThirdPartyLibsDialog'- ),-);-function ThirdPartyLibsDialogAsync(props) {- return (- <React.Suspense fallback={<LoadingLazy />}>- <ThirdPartyLibsDialog {...props} />- </React.Suspense>- );-}--const OnboardingDialog = React.lazy(- () =>- import(- /* webpackChunkName: "OnboardingDialog" */ '../components/dialogs/OnboardingDialog'- ),-);-function OnboardingDialogAsync(props) {- return (- <React.Suspense fallback={<LoadingLazy />}>- <OnboardingDialog {...props} />- </React.Suspense>- );-}--const EditEntryTagDialog = React.lazy(- () =>- import(- /* webpackChunkName: "EditEntryTagDialog" */ '../components/dialogs/EditEntryTagDialog'- ),-);-function EditEntryTagDialogAsync(props) {- return (- <React.Suspense fallback={<LoadingLazy />}>- <EditEntryTagDialog {...props} />- </React.Suspense>- );-}--const OpenLinkDialog = React.lazy(- () =>- import(- /* webpackChunkName: "OpenLinkDialog" */ '../components/dialogs/OpenLinkDialog'- ),-);-function OpenLinkDialogAsync(props) {- return (- <React.Suspense fallback={<LoadingLazy />}>- <OpenLinkDialog {...props} />- </React.Suspense>- );-}--const ProTeaserDialog = React.lazy(- () =>- import(- /* webpackChunkName: "ProTeaserDialog" */ '../components/dialogs/ProTeaserDialog'- ),-);-function ProTeaserDialogAsync(props) {- return (- <React.Suspense fallback={<LoadingLazy />}>- <ProTeaserDialog {...props} />- </React.Suspense>- );+ isHelpFeedbackPanelOpened: boolean;*/+ //user: CognitoUserInterface;}function MainPage(props: Props) {- const { t } = useTranslation();- const { deleteEntries } = useIOActionsContext();- const { selectedEntries } = useSelectedEntriesContext();const {openLink,openedEntry,@@ -336,27 +110,16 @@ function MainPage(props: Props) {exitSearchMode,openCurrentDirectory,} = useDirectoryContentContext();- const { showNotification } = useNotificationContext();+ const { showPanel } = usePanelsContext();+ const { isLoggedIn } = useUserContext();const theme = useTheme();const percent = useRef<number | undefined>(undefined);const [ignored, forceUpdate] = useReducer((x) => x + 1, 0, undefined);- const width =- window.innerWidth ||- document.documentElement.clientWidth ||- body.clientWidth;- const height =- window.innerHeight ||- document.documentElement.clientHeight ||- body.clientHeight;- const [dimensions, setDimensions] = useState<any>({- width,- height,- });-const [drawerOpened, setDrawerOpened] = useState<boolean>(true);- const [moveCopyDialogOpened, setMoveCopyDialogOpened] =- useState<any>(undefined);+ const isDesktopMode: boolean = useSelector(getDesktopMode);+ const keyBindings = useSelector(getKeyBindingObject);+ const mainSplitSize = useSelector(getMainVerticalSplitSize);useEventListener('message', (e) => {if (typeof e.data === 'string') {@@ -418,7 +181,7 @@ function MainPage(props: Props) {body.clientHeight;// console.log('Width: ' + width + ' Height: ' + height);- setDimensions({ width: w, height: h });+ //setDimensions({ width: w, height: h });if (openedEntry && !isEntryInFullWidth) {const isFillWidth = h > w;@@ -436,11 +199,11 @@ function MainPage(props: Props) {openParentDirectory: loadParentDirectoryContent,toggleShowHiddenEntries: props.toggleShowUnixHiddenEntries,showLocationManager: () => {- props.openLocationManagerPanel();+ showPanel('locationManagerPanel');setDrawerOpened(true);},showTagLibrary: () => {- props.openTagLibraryPanel();+ showPanel('tagLibraryPanel');setDrawerOpened(true);},openSearch: () => enterSearchMode(),@@ -449,43 +212,21 @@ function MainPage(props: Props) {openCurrentDirectory();},showHelp: () => {- props.openHelpFeedbackPanel();+ showPanel('helpFeedbackPanel');setDrawerOpened(true);},};const keyMap = {- openParentDirectory: props.keyBindings.openParentDirectory,- toggleShowHiddenEntries: props.keyBindings.toggleShowHiddenEntries,- showLocationManager: props.keyBindings.showLocationManager,- showTagLibrary: props.keyBindings.showTagLibrary,- openSearch: props.keyBindings.openSearch,- closeSearch: props.keyBindings.Escape,- showHelp: props.keyBindings.showHelp,+ openParentDirectory: keyBindings.openParentDirectory,+ toggleShowHiddenEntries: keyBindings.toggleShowHiddenEntries,+ showLocationManager: keyBindings.showLocationManager,+ showTagLibrary: keyBindings.showTagLibrary,+ openSearch: keyBindings.openSearch,+ closeSearch: keyBindings.Escape,+ showHelp: keyBindings.showHelp,};- const {- toggleOnboardingDialog,- toggleSettingsDialog,- toggleKeysDialog,- toggleLicenseDialog,- toggleThirdPartyLibsDialog,- toggleAboutDialog,- toggleLocationDialog,- toggleCreateDirectoryDialog,- toggleNewEntryDialog,- toggleNewFileDialog,- toggleNewAudioDialog,- //toggleUploadDialog,- toggleProgressDialog,- toggleEditTagDialog,- toggleOpenLinkDialog,- toggleProTeaser,- setFirstRun,- isDesktopMode,- mainSplitSize,- } = props;-const { FILE } = NativeTypes;const setPercent = (p: number | undefined) => {@@ -533,7 +274,6 @@ function MainPage(props: Props) {><FolderContainertoggleDrawer={toggleDrawer}- toggleProTeaser={toggleProTeaser}drawerOpened={drawerOpened}goBack={goBack}goForward={goForward}@@ -542,9 +282,9 @@ function MainPage(props: Props) {}*//>{openedEntry && (- <DescriptionContextProvider>+ <FilePropertiesContextProvider><EntryContainer key="EntryContainerID" />- </DescriptionContextProvider>+ </FilePropertiesContextProvider>)}</Split>);@@ -557,166 +297,6 @@ function MainPage(props: Props) {keyMap={keyMap}style={{ height: '100%' }}>- <MoveOrCopyFilesDialog- open={moveCopyDialogOpened !== undefined}- onClose={() => {- setMoveCopyDialogOpened(undefined);- }}- selectedFiles={moveCopyDialogOpened}- />- {props.isLocationDialogOpened && (- <CreateEditLocationDialogAsync- open={props.isLocationDialogOpened}- onClose={toggleLocationDialog}- />- )}- {props.isAboutDialogOpened && (- <AboutDialogAsync- open={props.isAboutDialogOpened}- toggleLicenseDialog={toggleLicenseDialog}- toggleThirdPartyLibsDialog={toggleThirdPartyLibsDialog}- onClose={toggleAboutDialog}- />- )}- {props.isKeysDialogOpened && (- <KeyboardDialogAsync- open={props.isKeysDialogOpened}- onClose={toggleKeysDialog}- />- )}- {props.isLicenseDialogOpened && (- <LicenseDialogAsync- open={props.isLicenseDialogOpened}- onClose={(event, reason) => {- if (reason === 'backdropClick' || reason === 'escapeKeyDown') {- return true;- }- setFirstRun(false);- toggleLicenseDialog();- }}- />- )}- {props.isOnboardingDialogOpened && (- <OnboardingDialogAsync- open={props.isOnboardingDialogOpened}- onClose={toggleOnboardingDialog}- />- )}- {props.isThirdPartyLibsDialogOpened && (- <ThirdPartyLibsDialogAsync- open={props.isThirdPartyLibsDialogOpened}- onClose={toggleThirdPartyLibsDialog}- />- )}- {props.isEditTagDialogOpened && (- <EditEntryTagDialogAsync- open={props.isEditTagDialogOpened}- onClose={() => toggleEditTagDialog(undefined)}- />- )}- {props.isOpenLinkDialogOpened && (- <OpenLinkDialogAsync- open={props.isOpenLinkDialogOpened}- onClose={toggleOpenLinkDialog}- />- )}- {props.isProTeaserVisible && (- <ProTeaserDialogAsync- open={props.isProTeaserVisible}- onClose={toggleProTeaser}- />- )}- {/*{props.isUploadProgressDialogOpened !== undefined && (- <FileUploadDialog- open={true}- onClose={toggleUploadDialog}- title={props.isUploadProgressDialogOpened}- />- )}*/}- {props.isTruncatedConfirmDialogOpened && (- <IsTruncatedConfirmDialog- open={true}- onClose={props.toggleTruncatedConfirmDialog}- />- )}- {props.isProgressDialogOpened && (- <ProgressDialog- open={props.isProgressDialogOpened}- onClose={toggleProgressDialog}- />- )}- {props.isCreateDirectoryOpened !== null && (- <CreateDirectoryDialog- open={true}- onClose={toggleCreateDirectoryDialog}- selectedDirectoryPath={props.isCreateDirectoryOpened?.rootDirPath}- callback={props.isCreateDirectoryOpened?.callback}- />- )}- <NewEntryDialog- open={props.isNewEntryDialogOpened}- onClose={(event, reason) => {- if (reason !== 'backdropClick') {- toggleNewEntryDialog();- }- }}- />- {props.isNewFileDialogOpened && (- <NewFileDialog- open={props.isNewFileDialogOpened}- onClose={(event, reason) => {- if (reason !== 'backdropClick') {- toggleNewFileDialog();- }- }}- />- )}- {props.isNewAudioDialogOpened && (- <NewAudioDialog- open={props.isNewAudioDialogOpened}- onClose={toggleNewAudioDialog}- />- )}- <SettingsDialog- open={props.isSettingsDialogOpened}- onClose={toggleSettingsDialog}- />- {KanBanImportDialog && selectedEntries[0] && (- <KanBanImportDialog- open={props.isImportKanBanDialogOpened}- onClose={props.toggleImportKanBanDialog}- />- )}- {props.isDeleteMultipleEntriesDialogOpened && (- <ConfirmDialog- open={props.isDeleteMultipleEntriesDialogOpened}- onClose={() => props.toggleDeleteMultipleEntriesDialog()}- title={t('core:deleteConfirmationTitle')}- content={t('core:deleteConfirmationContent')}- list={selectedEntries.map((fsEntry) => fsEntry.name)}- confirmCallback={(result) => {- if (result && selectedEntries) {- deleteEntries(...selectedEntries).then(- (success) =>- success &&- selectedEntries.length > 1 &&- showNotification(- t('core:deletingEntriesSuccessful', {- dirPath: selectedEntries- .map((fsEntry) => fsEntry.name)- .toString(),- }),- 'default',- true,- ),- );- }- }}- cancelDialogTID="cancelDeleteFileDialog"- confirmDialogTID="confirmDeleteFileDialog"- confirmDialogContentTID="confirmDeleteDialogContent"- />- )}<PageNotification /><divstyle={{@@ -752,11 +332,8 @@ function MainPage(props: Props) {}`}</style>- {isDesktopMode || (AppConfig.isAmplify && !props.user) ? (- <TargetFileBox- accepts={[FILE]}- setMoveCopyDialogOpened={setMoveCopyDialogOpened}- >+ {isDesktopMode || (AppConfig.isAmplify && !isLoggedIn()) ? (+ <TargetFileBox accepts={[FILE]}><CustomDragLayer /><Drawer variant="persistent" anchor="left" open={drawerOpened}><MobileNavigation width={drawerWidth} />@@ -795,111 +372,25 @@ function MainPage(props: Props) {function mapStateToProps(state) {return {- isEditTagDialogOpened: isEditTagDialogOpened(state),- isCreateDirectoryOpened: isCreateDirectoryOpened(state),- isNewEntryDialogOpened: isNewEntryDialogOpened(state),- isNewFileDialogOpened: isNewFileDialogOpened(state),- isNewAudioDialogOpened: isNewAudioDialogOpened(state),- isSettingsDialogOpened: isSettingsDialogOpened(state),- isAboutDialogOpened: isAboutDialogOpened(state),- isLocationDialogOpened: isLocationDialogOpened(state),- isKeysDialogOpened: isKeysDialogOpened(state),- isOnboardingDialogOpened: isOnboardingDialogOpened(state),- isLicenseDialogOpened: isLicenseDialogOpened(state),- isThirdPartyLibsDialogOpened: isThirdPartyLibsDialogOpened(state),- //isUploadProgressDialogOpened: isUploadDialogOpened(state),- isTruncatedConfirmDialogOpened: isTruncatedConfirmDialogOpened(state),- isOpenLinkDialogOpened: isOpenLinkDialogOpened(state),- isProTeaserVisible: isProTeaserVisible(state),- isProgressDialogOpened: isProgressOpened(state),- isDesktopMode: getDesktopMode(state),- keyBindings: getKeyBindingObject(state),- mainSplitSize: getMainVerticalSplitSize(state),- isLocationManagerPanelOpened: isLocationManagerPanelOpened(state),+ /*isLocationManagerPanelOpened: isLocationManagerPanelOpened(state),isTagLibraryPanelOpened: isTagLibraryPanelOpened(state),isSearchPanelOpened: isSearchPanelOpened(state),- isHelpFeedbackPanelOpened: isHelpFeedbackPanelOpened(state),- isDeleteMultipleEntriesDialogOpened:- isDeleteMultipleEntriesDialogOpened(state),- isImportKanBanDialogOpened: isImportKanBanDialogOpened(state),- user: currentUser(state),+ isHelpFeedbackPanelOpened: isHelpFeedbackPanelOpened(state),*/+ //user: currentUser(state),};}function mapDispatchToProps(dispatch) {return bindActionCreators({- toggleCreateDirectoryDialog: AppActions.toggleCreateDirectoryDialog,- //toggleUploadDialog: AppActions.toggleUploadDialog,- toggleProgressDialog: AppActions.toggleProgressDialog,- resetProgress: AppActions.resetProgress,- toggleEditTagDialog: AppActions.toggleEditTagDialog,- toggleTruncatedConfirmDialog: AppActions.toggleTruncatedConfirmDialog,- onUploadProgress: AppActions.onUploadProgress,- toggleNewEntryDialog: AppActions.toggleNewEntryDialog,- toggleNewFileDialog: AppActions.toggleNewFileDialog,- toggleNewAudioDialog: AppActions.toggleNewAudioDialog,- toggleSettingsDialog: AppActions.toggleSettingsDialog,- toggleKeysDialog: AppActions.toggleKeysDialog,- toggleLicenseDialog: AppActions.toggleLicenseDialog,- toggleImportKanBanDialog: AppActions.toggleImportKanBanDialog,- toggleThirdPartyLibsDialog: AppActions.toggleThirdPartyLibsDialog,- toggleAboutDialog: AppActions.toggleAboutDialog,- toggleLocationDialog: AppActions.toggleLocationDialog,- toggleOnboardingDialog: AppActions.toggleOnboardingDialog,- toggleOpenLinkDialog: AppActions.toggleOpenLinkDialog,- toggleProTeaser: AppActions.toggleProTeaser,toggleShowUnixHiddenEntries: SettingsActions.toggleShowUnixHiddenEntries,setMainVerticalSplitSize: SettingsActions.setMainVerticalSplitSize,- openLocationManagerPanel: AppActions.openLocationManagerPanel,- openTagLibraryPanel: AppActions.openTagLibraryPanel,- // openSearchPanel: AppActions.openSearchPanel,- openHelpFeedbackPanel: AppActions.openHelpFeedbackPanel,- // closeAllVerticalPanels: AppActions.closeAllVerticalPanels,- toggleDeleteMultipleEntriesDialog:- AppActions.toggleDeleteMultipleEntriesDialog,- setFirstRun: SettingsActions.setFirstRun,},dispatch,);}-const areEqual = (prevProp, nextProp) =>- /* JSON.stringify(nextProp.theme.palette) ===- JSON.stringify(prevProp.theme.palette) && */- nextProp.isAboutDialogOpened === prevProp.isAboutDialogOpened &&- JSON.stringify(nextProp.isCreateDirectoryOpened) ===- JSON.stringify(prevProp.isCreateDirectoryOpened) &&- nextProp.isNewEntryDialogOpened === prevProp.isNewEntryDialogOpened &&- nextProp.isNewFileDialogOpened === prevProp.isNewFileDialogOpened &&- nextProp.isNewAudioDialogOpened === prevProp.isNewAudioDialogOpened &&- nextProp.isDeleteMultipleEntriesDialogOpened ===- prevProp.isDeleteMultipleEntriesDialogOpened &&- nextProp.isDesktopMode === prevProp.isDesktopMode &&- nextProp.isEditTagDialogOpened === prevProp.isEditTagDialogOpened &&- nextProp.isHelpFeedbackPanelOpened === prevProp.isHelpFeedbackPanelOpened &&- nextProp.isKeysDialogOpened === prevProp.isKeysDialogOpened &&- nextProp.isLicenseDialogOpened === prevProp.isLicenseDialogOpened &&- nextProp.isLocationDialogOpened === prevProp.isLocationDialogOpened &&- nextProp.isLocationManagerPanelOpened ===- prevProp.isLocationManagerPanelOpened &&- nextProp.isOnboardingDialogOpened === prevProp.isOnboardingDialogOpened &&- nextProp.isOpenLinkDialogOpened === prevProp.isOpenLinkDialogOpened &&- nextProp.isProTeaserVisible === prevProp.isProTeaserVisible &&- nextProp.isProgressDialogOpened === prevProp.isProgressDialogOpened &&- nextProp.isSearchPanelOpened === prevProp.isSearchPanelOpened &&- nextProp.isSettingsDialogOpened === prevProp.isSettingsDialogOpened &&- nextProp.isTagLibraryPanelOpened === prevProp.isTagLibraryPanelOpened &&- nextProp.isTruncatedConfirmDialogOpened ===- prevProp.isTruncatedConfirmDialogOpened &&- nextProp.isThirdPartyLibsDialogOpened ===- prevProp.isThirdPartyLibsDialogOpened &&- /*nextProp.isUploadProgressDialogOpened ===- prevProp.isUploadProgressDialogOpened &&*/- nextProp.isImportKanBanDialogOpened === prevProp.isImportKanBanDialogOpened &&- nextProp.mainSplitSize === prevProp.mainSplitSize;-export default connect(mapStateToProps,mapDispatchToProps,-)(React.memo(MainPage, areEqual));+)(React.memo(MainPage));diff --git a/src/renderer/containers/Root.tsx b/src/renderer/containers/Root.tsxindex 798e16477..c97c73e3e 100644--- a/src/renderer/containers/Root.tsx+++ b/src/renderer/containers/Root.tsx@@ -47,6 +47,8 @@ import { PerspectiveActionsContextProvider } from '-/hooks/PerspectiveActionsConimport { Pro } from '-/pro';import DialogsRoot from '-/containers/DialogsRoot';import { ExtensionsContextProvider } from '-/hooks/ExtensionsContextProvider';+import { PanelsContextProvider } from '-/hooks/PanelsContextProvider';+import { UserContextProvider } from '-/hooks/UserContextProvider';type RootType = {store: Store<{}>;@@ -86,17 +88,23 @@ export default function Root({ store, persistor }: RootType) {<TaggingActionsContextProvider><DndProvider backend={HTML5Backend}><ExtensionsContextProvider>- <DialogsRoot>- {Pro ? (- <Pro.contextProviders.BookmarksContextProvider>- <Pro.contextProviders.HistoryContextProvider>+ <PanelsContextProvider>+ <UserContextProvider>+ <DialogsRoot>+ {Pro ? (+ <Pro.contextProviders.BookmarksContextProvider>+ <Pro.contextProviders.HistoryContextProvider>+ <Pro.contextProviders.KanBanImportDialogContextProvider>+ <MainPage />+ </Pro.contextProviders.KanBanImportDialogContextProvider>+ </Pro.contextProviders.HistoryContextProvider>+ </Pro.contextProviders.BookmarksContextProvider>+ ) : (<MainPage />- </Pro.contextProviders.HistoryContextProvider>- </Pro.contextProviders.BookmarksContextProvider>- ) : (- <MainPage />- )}- </DialogsRoot>+ )}+ </DialogsRoot>+ </UserContextProvider>+ </PanelsContextProvider></ExtensionsContextProvider></DndProvider></TaggingActionsContextProvider>diff --git a/src/renderer/content/ProTeaserSlides.tsx b/src/renderer/content/ProTeaserSlides.tsxindex 5676dc1b2..b796f18b3 100644--- a/src/renderer/content/ProTeaserSlides.tsx+++ b/src/renderer/content/ProTeaserSlides.tsx@@ -25,13 +25,6 @@ export const slidesNames = ['enterprise',];-export function getProTeaserSlideIndex(slideName: string): number {- if (!slideName) {- return -1;- }- return slidesNames.findIndex((key) => key === slideName);-}-export function getProTeaserSlides(t) {const slidesEN = [];slidesEN[slidesNames['general']] = {diff --git a/src/renderer/hooks/DirectoryContentContextProvider.tsx b/src/renderer/hooks/DirectoryContentContextProvider.tsxindex 1f10d545a..0a8ee68fd 100644--- a/src/renderer/hooks/DirectoryContentContextProvider.tsx+++ b/src/renderer/hooks/DirectoryContentContextProvider.tsx@@ -42,6 +42,7 @@ import AppConfig from '-/AppConfig';import { PerspectiveIDs } from '-/perspectives';import { updateHistory } from '-/utils/dom';import {+ actions as SettingsActions,getDefaultPerspective,getShowUnixHiddenEntries,getTagColor,@@ -61,6 +62,7 @@ import { useEditedEntryMetaContext } from '-/hooks/useEditedEntryMetaContext';import { useEditedKanBanMetaContext } from '-/hooks/useEditedKanBanMetaContext';import { CommonLocation } from '-/utils/CommonLocation';import { useCancelable } from '-/utils/useCancelable';+import LoadingLazy from '-/components/LoadingLazy';type DirectoryContentContextData = {currentLocationPath: string;@@ -133,6 +135,8 @@ type DirectoryContentContextData = {dirEntries: TS.FileSystemEntry[],pageFiles?: TS.FileSystemEntry[],) => Promise<TS.FileSystemEntry[]>;+ openIsTruncatedConfirmDialog: () => void;+ closeIsTruncatedConfirmDialog: () => void;};export const DirectoryContentContext =@@ -176,12 +180,21 @@ export const DirectoryContentContext =getPerspective: undefined,getAllPropertiesPromise: undefined,loadCurrentDirMeta: undefined,+ openIsTruncatedConfirmDialog: undefined,+ closeIsTruncatedConfirmDialog: undefined,});export type DirectoryContentContextProviderProps = {children: React.ReactNode;};+const IsTruncatedConfirmDialog = React.lazy(+ () =>+ import(+ /* webpackChunkName: "IsTruncatedConfirmDialog" */ '../components/dialogs/IsTruncatedConfirmDialog'+ ),+);+export const DirectoryContentContextProvider = ({children,}: DirectoryContentContextProviderProps) => {@@ -218,6 +231,7 @@ export const DirectoryContentContextProvider = ({//const currentPerspective = useRef<TS.PerspectiveType>('unspecified');const manualPerspective = useRef<TS.PerspectiveType>('unspecified');const directoryMeta = useRef<TS.FileSystemEntryMeta>(getDefaultDirMeta());+ const open = useRef<boolean>(false);/*** isMetaLoaded boolean if thumbs and description from meta are loaded* is using why directoryMeta can be loaded but empty@@ -232,6 +246,36 @@ export const DirectoryContentContextProvider = ({// const firstRender = useFirstRender();const [ignored, forceUpdate] = useReducer((x) => x + 1, 0, undefined);+ useEffect(() => {+ if (AppConfig.isElectron) {+ window.electronIO.ipcRenderer.on('cmd', (arg) => {+ if (arg === 'open-search') {+ setSearchQuery({ textQuery: '' });+ } else if (arg === 'exit-fullscreen') {+ try {+ if (document.fullscreenElement) {+ document.exitFullscreen();+ }+ } catch (e) {+ console.log('Failed to exit fullscreen mode:', e);+ }+ } else if (arg === 'set-zoom-reset-app') {+ dispatch(SettingsActions.setZoomResetApp());+ } else if (arg === 'set-zoom-in-app') {+ dispatch(SettingsActions.setZoomInApp());+ } else if (arg === 'set-zoom-out-app') {+ dispatch(SettingsActions.setZoomOutApp());+ }+ });++ return () => {+ if (window.electronIO.ipcRenderer) {+ window.electronIO.ipcRenderer.removeAllListeners('cmd');+ }+ };+ }+ }, []);+useEffect(() => {if (currentLocation) {// check for relative path for Location@@ -741,8 +785,7 @@ export const DirectoryContentContextProvider = ({return [];}if (resultsLimit.IsTruncated) {- //OPEN ISTRUNCATED dialog- dispatch(AppActions.toggleTruncatedConfirmDialog());+ openIsTruncatedConfirmDialog();}if (results !== undefined) {// console.debug('app listDirectoryPromise resolved:' + results.length);@@ -1362,6 +1405,24 @@ export const DirectoryContentContextProvider = ({});}+ function openIsTruncatedConfirmDialog() {+ open.current = true;+ forceUpdate();+ }++ function closeIsTruncatedConfirmDialog() {+ open.current = false;+ forceUpdate();+ }++ function IsTruncatedConfirmDialogAsync(props) {+ return (+ <React.Suspense fallback={<LoadingLazy />}>+ <IsTruncatedConfirmDialog {...props} />+ </React.Suspense>+ );+ }+const context = useMemo(() => {return {currentLocationPath: currentLocationPath.current,@@ -1403,6 +1464,8 @@ export const DirectoryContentContextProvider = ({getDefaultPerspectiveSettings,getAllPropertiesPromise,loadCurrentDirMeta,+ openIsTruncatedConfirmDialog,+ closeIsTruncatedConfirmDialog,};}, [currentLocation,@@ -1420,6 +1483,10 @@ export const DirectoryContentContextProvider = ({return (<DirectoryContentContext.Provider value={context}>+ <IsTruncatedConfirmDialogAsync+ open={open.current}+ onClose={closeIsTruncatedConfirmDialog}+ />{children}</DirectoryContentContext.Provider>);diff --git a/src/renderer/hooks/DescriptionContextProvider.tsx b/src/renderer/hooks/FilePropertiesContextProvider.tsxsimilarity index 90%rename from src/renderer/hooks/DescriptionContextProvider.tsxrename to src/renderer/hooks/FilePropertiesContextProvider.tsxindex 4e5f0a3f9..1441cd10b 100644--- a/src/renderer/hooks/DescriptionContextProvider.tsx+++ b/src/renderer/hooks/FilePropertiesContextProvider.tsx@@ -32,7 +32,7 @@ import { useNotificationContext } from '-/hooks/useNotificationContext';import { TS } from '-/tagspaces.namespace';import { useIOActionsContext } from '-/hooks/useIOActionsContext';-type DescriptionContextData = {+type FilePropertiesContextData = {description: string;isSaveDescriptionConfirmOpened: boolean;isEditMode: boolean;@@ -42,7 +42,7 @@ type DescriptionContextData = {saveDescription: () => void;};-export const DescriptionContext = createContext<DescriptionContextData>({+export const FilePropertiesContext = createContext<FilePropertiesContextData>({description: undefined,isSaveDescriptionConfirmOpened: false,isEditMode: false,@@ -52,13 +52,13 @@ export const DescriptionContext = createContext<DescriptionContextData>({saveDescription: undefined,});-export type DescriptionContextProviderProps = {+export type FilePropertiesContextProviderProps = {children: React.ReactNode;};-export const DescriptionContextProvider = ({+export const FilePropertiesContextProvider = ({children,-}: DescriptionContextProviderProps) => {+}: FilePropertiesContextProviderProps) => {const { t } = useTranslation();const { openedEntry } = useOpenedEntryContext();const { findLocation } = useCurrentLocationContext();@@ -134,10 +134,12 @@ export const DescriptionContextProvider = ({}function setEditMode(editMode: boolean) {- isEditMode.current = editMode;- isChanged.current = false;- lastOpenedFile.current = { ...openedEntry };- forceUpdate();+ if (isEditMode.current !== editMode) {+ isEditMode.current = editMode;+ isChanged.current = false;+ lastOpenedFile.current = { ...openedEntry };+ forceUpdate();+ }}function setSaveDescriptionConfirmOpened(isOpened: boolean) {@@ -165,8 +167,8 @@ export const DescriptionContextProvider = ({]);return (- <DescriptionContext.Provider value={context}>+ <FilePropertiesContext.Provider value={context}>{children}- </DescriptionContext.Provider>+ </FilePropertiesContext.Provider>);};diff --git a/src/renderer/hooks/OpenedEntryContextProvider.tsx b/src/renderer/hooks/OpenedEntryContextProvider.tsxindex 59c166fad..9efaddca3 100644--- a/src/renderer/hooks/OpenedEntryContextProvider.tsx+++ b/src/renderer/hooks/OpenedEntryContextProvider.tsx@@ -65,13 +65,16 @@ import { usePlatformFacadeContext } from '-/hooks/usePlatformFacadeContext';import { useEditedEntryContext } from '-/hooks/useEditedEntryContext';import { useEditedEntryMetaContext } from '-/hooks/useEditedEntryMetaContext';import { CommonLocation } from '-/utils/CommonLocation';+import { useFilePropertiesContext } from '-/hooks/useFilePropertiesContext';type OpenedEntryContextData = {openedEntry: TS.OpenedEntry;+ fileChanged: boolean;isEntryInFullWidth: boolean;sharingLink: string;sharingParentFolderLink: string;setEntryInFullWidth: (fullWidth: boolean) => void;+ setFileChanged: (isChanged: boolean) => void;addToEntryContainer: (fsEntry: TS.OpenedEntry) => void;closeAllFiles: () => void;reflectUpdateOpenedFileContent: (entry: TS.FileSystemEntry) => void;@@ -104,10 +107,12 @@ type OpenedEntryContextData = {export const OpenedEntryContext = createContext<OpenedEntryContextData>({openedEntry: undefined,+ fileChanged: false,isEntryInFullWidth: false,sharingLink: undefined,sharingParentFolderLink: undefined,- setEntryInFullWidth: () => {},+ setEntryInFullWidth: undefined,+ setFileChanged: undefined,addToEntryContainer: () => {},closeAllFiles: () => {},reflectUpdateOpenedFileContent: () => {},@@ -151,6 +156,7 @@ export const OpenedEntryContextProvider = ({const { actions } = useEditedEntryContext();const { metaActions } = useEditedEntryMetaContext();const { saveFilePromise } = usePlatformFacadeContext();+ const { setEditMode, isEditMode } = useFilePropertiesContext();const supportedFileTypes = useSelector(getSupportedFileTypes);//const locations: CommonLocation[] = useSelector(getLocations);@@ -161,6 +167,7 @@ export const OpenedEntryContextProvider = ({filesCount: undefined,dirsCount: undefined,});*/+ const fileChanged = useRef<boolean>(false);const isEntryInFullWidth = useRef<boolean>(false);const sharingLink = useRef<string>(undefined);const sharingParentFolderLink = useRef<string>(undefined);@@ -186,6 +193,21 @@ export const OpenedEntryContextProvider = ({}, 1000);}}+ if (AppConfig.isElectron) {+ window.electronIO.ipcRenderer.on('cmd', (arg) => {+ if (arg === 'go-back') {+ goBack();+ } else if (arg === 'go-forward') {+ goForward();+ }+ });++ return () => {+ if (window.electronIO.ipcRenderer) {+ window.electronIO.ipcRenderer.removeAllListeners('cmd');+ }+ };+ }}, []);useEffect(() => {@@ -460,7 +482,7 @@ export const OpenedEntryContextProvider = ({function reloadOpenedFile(): Promise<boolean> {if (currentEntry.current) {- currentEntry.current.editMode = false;+ //currentEntry.current.editMode = false;//return openEntry(currentEntry.current.path); //true);return getAllPropertiesPromise(currentEntry.current.path,@@ -547,7 +569,7 @@ export const OpenedEntryContextProvider = ({if (currentEntry.current) {//openedEntries.length > 0) {const openFile = currentEntry.current; //openedEntries[0];- if (openFile.editMode) {+ if (isEditMode) {entryForOpening = {...openFile,}; // false };@@ -577,7 +599,7 @@ export const OpenedEntryContextProvider = ({fsEntry.isNewFile &&AppConfig.editableFiles.includes(fsEntry.extension)) {- entryForOpening.editMode = true;+ setEditMode(true);}const locationName = loc ? loc.name : 'TagSpaces'; // TODO get it later from app config@@ -605,6 +627,13 @@ export const OpenedEntryContextProvider = ({forceUpdate();}+ function setFileChanged(isChanged) {+ if (fileChanged.current !== isChanged) {+ fileChanged.current = isChanged;+ forceUpdate();+ }+ }+function goForward() {window.history.forward();window.addEventListener(@@ -927,10 +956,12 @@ export const OpenedEntryContextProvider = ({const context = useMemo(() => {return {openedEntry: currentEntry.current,+ fileChanged: fileChanged.current,isEntryInFullWidth: isEntryInFullWidth.current,sharingLink: sharingLink.current,sharingParentFolderLink: sharingParentFolderLink.current,setEntryInFullWidth,+ setFileChanged,addToEntryContainer,closeAllFiles,reflectUpdateOpenedFileContent,@@ -950,6 +981,7 @@ export const OpenedEntryContextProvider = ({getOpenedDirProps,};}, [+ fileChanged.current,currentEntry.current,isEntryInFullWidth.current,currentLocation,diff --git a/src/renderer/hooks/PanelsContextProvider.tsx b/src/renderer/hooks/PanelsContextProvider.tsxnew file mode 100644index 000000000..b9e25bd60--- /dev/null+++ b/src/renderer/hooks/PanelsContextProvider.tsx@@ -0,0 +1,82 @@+/**+ * TagSpaces - universal file and folder organizer+ * Copyright (C) 2023-present TagSpaces UG (haftungsbeschraenkt)+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License (version 3) as+ * published by the Free Software Foundation.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <https://www.gnu.org/licenses/>.+ *+ */++import React, { createContext, useEffect, useMemo, useRef } from 'react';+import AppConfig from '-/AppConfig';++type PanelType =+ | 'locationManagerPanel'+ | 'tagLibraryPanel'+ | 'searchPanel'+ | 'helpFeedbackPanel';+type PanelsContextData = {+ currentOpenedPanel: PanelType;+ showPanel: (panel: PanelType) => void;+};++export const PanelsContext = createContext<PanelsContextData>({+ currentOpenedPanel: undefined,+ showPanel: undefined,+});++export type PanelsContextProviderProps = {+ children: React.ReactNode;+};++export const PanelsContextProvider = ({+ children,+}: PanelsContextProviderProps) => {+ const currentOpenedPanel = useRef<PanelType>('locationManagerPanel');+ const [ignored, forceUpdate] = React.useReducer((x) => x + 1, 0, undefined);++ useEffect(() => {+ if (AppConfig.isElectron) {+ window.electronIO.ipcRenderer.on('cmd', (arg) => {+ if (arg === 'open-location-manager-panel') {+ showPanel('locationManagerPanel');+ } else if (arg === 'open-tag-library-panel') {+ showPanel('tagLibraryPanel');+ } else if (arg === 'open-help-feedback-panel') {+ showPanel('helpFeedbackPanel');+ }+ });++ return () => {+ if (window.electronIO.ipcRenderer) {+ window.electronIO.ipcRenderer.removeAllListeners('cmd');+ }+ };+ }+ }, []);++ function showPanel(panel: PanelType) {+ currentOpenedPanel.current = panel;+ forceUpdate();+ }++ const context = useMemo(() => {+ return {+ currentOpenedPanel: currentOpenedPanel.current,+ showPanel: showPanel,+ };+ }, [currentOpenedPanel.current]);++ return (+ <PanelsContext.Provider value={context}>{children}</PanelsContext.Provider>+ );+};diff --git a/src/renderer/hooks/PerspectiveActionsContextProvider.tsx b/src/renderer/hooks/PerspectiveActionsContextProvider.tsxindex acc7663ca..60ed4a26e 100644--- a/src/renderer/hooks/PerspectiveActionsContextProvider.tsx+++ b/src/renderer/hooks/PerspectiveActionsContextProvider.tsx@@ -16,8 +16,16 @@**/-import React, { createContext, useMemo, useReducer, useRef } from 'react';+import React, {+ createContext,+ useEffect,+ useMemo,+ useReducer,+ useRef,+} from 'react';import { TS } from '-/tagspaces.namespace';+import { getURLParameter } from '-/utils/dom';+import AppConfig from '-/AppConfig';type PerspectiveActionsContextData = {actions: TS.PerspectiveActions[];@@ -41,6 +49,30 @@ export const PerspectiveActionsContextProvider = ({const [ignored, forceUpdate] = useReducer((x) => x + 1, 0, undefined);+ useEffect(() => {+ if (AppConfig.isElectron) {+ window.electronIO.ipcRenderer.on('cmd', (arg) => {+ if (arg === 'next-file') {+ const action: TS.PerspectiveActions = {+ action: 'openNext',+ };+ setActions(action);+ } else if (arg === 'previous-file') {+ const action: TS.PerspectiveActions = {+ action: 'openPrevious',+ };+ setActions(action);+ }+ });++ return () => {+ if (window.electronIO.ipcRenderer) {+ window.electronIO.ipcRenderer.removeAllListeners('cmd');+ }+ };+ }+ }, []);+function setActions(...actionsArray: TS.PerspectiveActions[]) {actions.current = actionsArray;forceUpdate();diff --git a/src/renderer/hooks/RendererListenerContextProvider.tsx b/src/renderer/hooks/RendererListenerContextProvider.tsxdeleted file mode 100644index 460aa2755..000000000--- a/src/renderer/hooks/RendererListenerContextProvider.tsx+++ /dev/null@@ -1,257 +0,0 @@-/**- * TagSpaces - universal file and folder organizer- * Copyright (C) 2023-present TagSpaces UG (haftungsbeschraenkt)- *- * This program is free software: you can redistribute it and/or modify- * it under the terms of the GNU Affero General Public License (version 3) as- * published by the Free Software Foundation.- *- * This program is distributed in the hope that it will be useful,- * but WITHOUT ANY WARRANTY; without even the implied warranty of- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- * GNU Affero General Public License for more details.- *- * You should have received a copy of the GNU Affero General Public License- * along with this program. If not, see <https://www.gnu.org/licenses/>.- *- */--import React, { createContext, useEffect, useMemo } from 'react';-import { useDispatch } from 'react-redux';-import { actions as AppActions, AppDispatch } from '-/reducers/app';-import { useOpenedEntryContext } from '-/hooks/useOpenedEntryContext';-import { useDirectoryContentContext } from '-/hooks/useDirectoryContentContext';-import AppConfig from '-/AppConfig';-import { actions as SettingsActions } from '-/reducers/settings';-import { getNextFile, getPrevFile } from '-/services/utils-io';-import { useSortedDirContext } from '-/perspectives/grid/hooks/useSortedDirContext';-import { useSelectedEntriesContext } from '-/hooks/useSelectedEntriesContext';-import useEventListener from '-/utils/useEventListener';--type RendererListenerContextData = {- openNextFile: (path?: string) => void;- openPrevFile: (path?: string) => void;-};--export const RendererListenerContext =- createContext<RendererListenerContextData>({- openNextFile: undefined,- openPrevFile: undefined,- });--export type RendererListenerContextProviderProps = {- children: React.ReactNode;-};--/**- * @deprecated find better places for this- * @param children- * @constructor- */-export const RendererListenerContextProvider = ({- children,-}: RendererListenerContextProviderProps) => {- const dispatch: AppDispatch = useDispatch();- const { selectedEntries, setSelectedEntries } = useSelectedEntriesContext();- const { setSearchQuery } = useDirectoryContentContext();- const { goForward, goBack, openFsEntry } = useOpenedEntryContext();- const { sortedDirContent } = useSortedDirContext();-- useEffect(() => {- if (AppConfig.isElectron) {- //const electron = window.require('electron');- //({ ipcRenderer } = electron);-- destroy();-- window.electronIO.ipcRenderer.on('cmd', (arg) => {- // console.log('Global events: ' + arg);- switch (arg) {- case 'new-text-file':- dispatch(AppActions.toggleNewFileDialog());- break;- case 'open-search':- setSearchQuery({ textQuery: '' });- break;- case 'open-location-manager-panel':- dispatch(AppActions.openLocationManagerPanel());- break;- case 'open-tag-library-panel':- dispatch(AppActions.openTagLibraryPanel());- break;- case 'audio':- // console.log('showAudioRecordingDialog');- break;- case 'next-file': {- openNextFile();- break;- }- case 'previous-file': {- openPrevFile();- break;- }- case 'show-create-directory-dialog': {- dispatch(AppActions.showCreateDirectoryDialog());- break;- }- case 'toggle-open-link-dialog': {- dispatch(AppActions.toggleOpenLinkDialog());- break;- }- case 'go-back': {- goBack();- break;- }- case 'go-forward': {- goForward();- break;- }- case 'set-zoom-reset-app': {- dispatch(SettingsActions.setZoomResetApp());- break;- }- case 'set-zoom-in-app': {- dispatch(SettingsActions.setZoomInApp());- break;- }- case 'set-zoom-out-app': {- dispatch(SettingsActions.setZoomOutApp());- break;- }- case 'exit-fullscreen': {- try {- if (document.fullscreenElement) {- document.exitFullscreen();- }- } catch (e) {- console.log('Failed to exit fullscreen mode:', e);- }- break;- }- case 'toggle-settings-dialog': {- dispatch(AppActions.toggleSettingsDialog());- break;- }- case 'open-help-feedback-panel': {- dispatch(AppActions.openHelpFeedbackPanel());- break;- }- case 'toggle-keys-dialog': {- dispatch(AppActions.toggleKeysDialog());- break;- }- case 'toggle-onboarding-dialog': {- dispatch(AppActions.toggleOnboardingDialog());- break;- }- /*case 'open-url-externally': {- props.openURLExternally();- break;- }*/- case 'toggle-license-dialog': {- dispatch(AppActions.toggleLicenseDialog());- break;- }- case 'toggle-third-party-libs-dialog': {- dispatch(AppActions.toggleThirdPartyLibsDialog());- break;- }- case 'toggle-about-dialog': {- dispatch(AppActions.toggleAboutDialog());- break;- }- default:- return false;- }- });-- /*ipcRenderer.on('open-url-externally', (event, arg) => {- const { url, skipConfirm } = arg;- props.openURLExternally(url, skipConfirm);- });*/-- window.electronIO.ipcRenderer.on('play-pause', () => {- // Create the event.- const audioEvent = new CustomEvent('toggle-resume', { detail: '' });- window.dispatchEvent(audioEvent);- });-- /* window.electronIO.ipcRenderer.on('set_extensions', (arg: Extensions) => {- const { extensions, supportedFileTypes } = arg;- dispatch(AppActions.addExtensions(extensions));- dispatch(SettingsActions.addSupportedFileTypes(supportedFileTypes));- //console.debug('extensions', extensions);- //console.debug('supportedFileTypes', supportedFileTypes);- });*/-- /*ipcRenderer.on('start_ws', (event, arg) => {- const { port } = arg;- console.debug('RendererListener start_ws port:' + port);- settings.setUsedWsPort(port);- });*/- return () => {- destroy();- };- }- }, [sortedDirContent, selectedEntries]);-- useEventListener('previous-file', (e) => {- openPrevFile();- });- useEventListener('next-file', (e) => {- openNextFile();- });-- function destroy() {- if (window.electronIO.ipcRenderer) {- window.electronIO.ipcRenderer.removeAllListeners('cmd');- window.electronIO.ipcRenderer.removeAllListeners('play-pause');- //window.electronIO.ipcRenderer.removeAllListeners('set_extensions');- window.electronIO.ipcRenderer.removeAllListeners('start_ws');- }- }-- function openNextFile(path?: string) {- const nextFile = getNextFile(- path,- selectedEntries && selectedEntries.length > 0- ? selectedEntries[selectedEntries.length - 1].path- : undefined,- sortedDirContent,- );- if (nextFile !== undefined) {- openFsEntry(nextFile);- // dispatch(actions.setLastSelectedEntry(nextFile.path));- setSelectedEntries([nextFile]);- return nextFile;- }- }-- function openPrevFile(path?: string) {- const prevFile = getPrevFile(- path,- selectedEntries && selectedEntries.length > 0- ? selectedEntries[selectedEntries.length - 1].path- : undefined,- sortedDirContent,- );- if (prevFile !== undefined) {- openFsEntry(prevFile);- // dispatch(actions.setLastSelectedEntry(prevFile.path));- setSelectedEntries([prevFile]);- }- }-- const context = useMemo(() => {- return {- openNextFile,- openPrevFile,- };- }, [sortedDirContent, selectedEntries]);-- return (- <RendererListenerContext.Provider value={context}>- {children}- </RendererListenerContext.Provider>- );-};diff --git a/src/renderer/hooks/TaggingActionsContextProvider.tsx b/src/renderer/hooks/TaggingActionsContextProvider.tsxindex 998c0e8e6..5cb8926f3 100644--- a/src/renderer/hooks/TaggingActionsContextProvider.tsx+++ b/src/renderer/hooks/TaggingActionsContextProvider.tsx@@ -16,7 +16,7 @@**/-import React, { createContext, useMemo } from 'react';+import React, { createContext, useMemo, useReducer, useRef } from 'react';import { useDispatch, useSelector } from 'react-redux';import { actions as AppActions, AppDispatch } from '-/reducers/app';import mgrs from 'mgrs';@@ -58,6 +58,7 @@ import { useTagGroupsLocationContext } from '-/hooks/useTagGroupsLocationContextimport AppConfig from '-/AppConfig';import { useEditedTagLibraryContext } from '-/hooks/useEditedTagLibraryContext';import { CommonLocation } from '-/utils/CommonLocation';+import LoadingLazy from '-/components/LoadingLazy';type extractOptions = {EXIFGeo?: boolean;@@ -113,6 +114,8 @@ type TaggingActionsContextData = {replace?: boolean,location?: CommonLocation,) => void;+ openEditEntryTagDialog: (tag: TS.Tag) => void;+ closeEditEntryTagDialog: () => void;};export const TaggingActionsContext = createContext<TaggingActionsContextData>({@@ -139,12 +142,21 @@ export const TaggingActionsContext = createContext<TaggingActionsContextData>({sortTagGroup: undefined,updateTagGroup: undefined,importTagGroups: undefined,+ openEditEntryTagDialog: undefined,+ closeEditEntryTagDialog: undefined,});export type TaggingActionsContextProviderProps = {children: React.ReactNode;};+const EditEntryTagDialog = React.lazy(+ () =>+ import(+ /* webpackChunkName: "EditEntryTagDialog" */ '../components/dialogs/EditEntryTagDialog'+ ),+);+export const TaggingActionsContextProvider = ({children,}: TaggingActionsContextProviderProps) => {@@ -165,7 +177,10 @@ export const TaggingActionsContextProvider = ({useIOActionsContext();const { reflectUpdateMeta, setReflectActions } = useEditedEntryContext();const { showNotification, hideNotifications } = useNotificationContext();- const dispatch: AppDispatch = useDispatch();++ const open = useRef<boolean>(false);+ const selectedTag = useRef<TS.Tag>(undefined);+const geoTaggingFormat = useSelector(getGeoTaggingFormat);const addTagsToLibrary = useSelector(getAddTagsToLibrary);const tagBackgroundColor: string = useSelector(getTagColor);@@ -175,6 +190,7 @@ export const TaggingActionsContextProvider = ({//const locations: CommonLocation[] = useSelector(getLocations);const saveTagInLocation: boolean = useSelector(getSaveTagInLocation);const filenameTagPlacedAtEnd = useSelector(getFileNameTagPlace);+ const [ignored, forceUpdate] = useReducer((x) => x + 1, 0, undefined);function extractContent(options: extractOptions = {@@ -301,7 +317,7 @@ export const TaggingActionsContextProvider = ({if (Pro) {tag.path = paths[0]; // todo rethink and remove this!tag.title = defaultTagLocation;- dispatch(AppActions.toggleEditTagDialog(tag));+ openEditEntryTagDialog(tag);} else {showNotification(t('core:thisFunctionalityIsAvailableInPro' as any) as string,@@ -312,7 +328,7 @@ export const TaggingActionsContextProvider = ({tag.path = paths[0]; // todo rethink and remove this!// delete tag.functionality;tag.title = formatDateTime4Tag(new Date(), true); // defaultTagDate;- dispatch(AppActions.toggleEditTagDialog(tag));+ openEditEntryTagDialog(tag);} else {showNotification(t('core:thisFunctionalityIsAvailableInPro' as any) as string,@@ -1451,6 +1467,25 @@ export const TaggingActionsContextProvider = ({saveTagLibrary(arr);}+ function openEditEntryTagDialog(tag: TS.Tag) {+ open.current = true;+ selectedTag.current = tag;+ forceUpdate();+ }++ function closeEditEntryTagDialog() {+ open.current = false;+ forceUpdate();+ }++ function EditEntryTagDialogAsync(props) {+ return (+ <React.Suspense fallback={<LoadingLazy />}>+ <EditEntryTagDialog {...props} />+ </React.Suspense>+ );+ }+const context = useMemo(() => {return {extractContent,@@ -1476,6 +1511,8 @@ export const TaggingActionsContextProvider = ({sortTagGroup,updateTagGroup,importTagGroups,+ openEditEntryTagDialog,+ closeEditEntryTagDialog,};}, [tagGroups,@@ -1488,6 +1525,11 @@ export const TaggingActionsContextProvider = ({return (<TaggingActionsContext.Provider value={context}>+ <EditEntryTagDialogAsync+ open={open.current}+ onClose={closeEditEntryTagDialog}+ tag={selectedTag.current}+ />{children}</TaggingActionsContext.Provider>);diff --git a/src/renderer/hooks/UserContextProvider.tsx b/src/renderer/hooks/UserContextProvider.tsxnew file mode 100644index 000000000..270ff5c84--- /dev/null+++ b/src/renderer/hooks/UserContextProvider.tsx@@ -0,0 +1,71 @@+/**+ * TagSpaces - universal file and folder organizer+ * Copyright (C) 2023-present TagSpaces UG (haftungsbeschraenkt)+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License (version 3) as+ * published by the Free Software Foundation.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <https://www.gnu.org/licenses/>.+ *+ */++import React, { createContext, useMemo, useRef } from 'react';+import { CognitoUserInterface } from '@aws-amplify/ui-components';++type UserContextData = {+ currentUser: CognitoUserInterface;+ loggedIn: (authData: any) => void;+ isLoggedIn: () => boolean;+};++export const UserContext = createContext<UserContextData>({+ currentUser: undefined,+ loggedIn: undefined,+ isLoggedIn: undefined,+});++export type UserContextProviderProps = {+ children: React.ReactNode;+};++export const UserContextProvider = ({ children }: UserContextProviderProps) => {+ // Create a factory function to generate a CognitoUserInterface object+ const createCognitoUser = (attributes: any): CognitoUserInterface => {+ return {+ attributes: attributes,+ associateSoftwareToken: () => {},+ verifySoftwareToken: () => {},+ challengeName: '',+ challengeParam: {},+ };+ };++ const user = useRef<CognitoUserInterface>(+ window.ExtDemoUser ? createCognitoUser(window.ExtDemoUser) : undefined,+ );+ const [ignored, forceUpdate] = React.useReducer((x) => x + 1, 0, undefined);++ function loggedIn(authData: CognitoUserInterface) {+ user.current = authData;+ forceUpdate();+ }++ const context = useMemo(() => {+ return {+ currentUser: user.current,+ loggedIn: loggedIn,+ isLoggedIn: () => user.current !== undefined,+ };+ }, [user.current]);++ return (+ <UserContext.Provider value={context}>{children}</UserContext.Provider>+ );+};diff --git a/src/renderer/hooks/useRendererListenerContext.tsx b/src/renderer/hooks/useFilePropertiesContext.tsxsimilarity index 82%rename from src/renderer/hooks/useRendererListenerContext.tsxrename to src/renderer/hooks/useFilePropertiesContext.tsxindex d8173e3da..0f5cd608c 100644--- a/src/renderer/hooks/useRendererListenerContext.tsx+++ b/src/renderer/hooks/useFilePropertiesContext.tsx@@ -18,7 +18,6 @@import { useContext } from 'react';-import { RendererListenerContext } from './RendererListenerContextProvider';+import { FilePropertiesContext } from './FilePropertiesContextProvider';-export const useRendererListenerContext = () =>- useContext(RendererListenerContext);+export const useFilePropertiesContext = () => useContext(FilePropertiesContext);diff --git a/src/renderer/hooks/useDescriptionContext.tsx b/src/renderer/hooks/usePanelsContext.tsxsimilarity index 84%rename from src/renderer/hooks/useDescriptionContext.tsxrename to src/renderer/hooks/usePanelsContext.tsxindex 568bc8ad9..fe82bddc8 100644--- a/src/renderer/hooks/useDescriptionContext.tsx+++ b/src/renderer/hooks/usePanelsContext.tsx@@ -18,6 +18,6 @@import { useContext } from 'react';-import { DescriptionContext } from './DescriptionContextProvider';+import { PanelsContext } from './PanelsContextProvider';-export const useDescriptionContext = () => useContext(DescriptionContext);+export const usePanelsContext = () => useContext(PanelsContext);diff --git a/src/renderer/hooks/useUserContext.tsx b/src/renderer/hooks/useUserContext.tsxnew file mode 100644index 000000000..04f3eaa11--- /dev/null+++ b/src/renderer/hooks/useUserContext.tsx@@ -0,0 +1,23 @@+/**+ * TagSpaces - universal file and folder organizer+ * Copyright (C) 2023-present TagSpaces UG (haftungsbeschraenkt)+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License (version 3) as+ * published by the Free Software Foundation.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <https://www.gnu.org/licenses/>.+ *+ */++import { useContext } from 'react';++import { UserContext } from './UserContextProvider';++export const useUserContext = () => useContext(UserContext);diff --git a/src/renderer/perspectives/grid/components/MainContainer.tsx b/src/renderer/perspectives/grid/components/MainContainer.tsxindex 4c34da744..a0ad9f767 100644--- a/src/renderer/perspectives/grid/components/MainContainer.tsx+++ b/src/renderer/perspectives/grid/components/MainContainer.tsx@@ -26,7 +26,6 @@ import EntryTagMenu from '-/components/menus/EntryTagMenu';import AddRemoveTagsDialog from '-/components/dialogs/AddRemoveTagsDialog';import MoveCopyFilesDialog from '-/components/dialogs/MoveCopyFilesDialog';import TagDropContainer from '-/components/TagDropContainer';-import { actions as AppActions, AppDispatch } from '-/reducers/app';import GridCell from './GridCell';import MainToolbar from '-/perspectives/grid/components/MainToolbar';import SortingMenu from '-/perspectives/grid/components/SortingMenu';@@ -46,11 +45,11 @@ import { useDirectoryContentContext } from '-/hooks/useDirectoryContentContext';import { useSelectedEntriesContext } from '-/hooks/useSelectedEntriesContext';import { usePerspectiveSettingsContext } from '-/hooks/usePerspectiveSettingsContext';import { GridCellsStyleContextProvider } from '-/perspectives/grid/hooks/GridCellsStyleProvider';-import { useRendererListenerContext } from '-/hooks/useRendererListenerContext';import { useIOActionsContext } from '-/hooks/useIOActionsContext';import { useCurrentLocationContext } from '-/hooks/useCurrentLocationContext';import { usePerspectiveActionsContext } from '-/hooks/usePerspectiveActionsContext';import useFirstRender from '-/utils/useFirstRender';+import { useDeleteMultipleEntriesDialogContext } from '-/components/dialogs/hooks/useDeleteMultipleEntriesDialogContext';interface Props {openRenameEntryDialog: () => void;@@ -59,14 +58,14 @@ interface Props {function GridPerspective(props: Props) {const { openRenameEntryDialog } = props;- const { openEntry } = useOpenedEntryContext();+ const { openEntry, openPrevFile, openNextFile } = useOpenedEntryContext();const { actions } = usePerspectiveActionsContext();- const { openPrevFile, openNextFile } = useRendererListenerContext();const { showDirectories } = usePerspectiveSettingsContext();const { currentLocation } = useCurrentLocationContext();const { openDirectory, currentDirectoryPath } = useDirectoryContentContext();const { openFileNatively, duplicateFile } = useIOActionsContext();- const dispatch: AppDispatch = useDispatch();+ const { openDeleteMultipleEntriesDialog } =+ useDeleteMultipleEntriesDialogContext();const { sortedDirContent, sortBy, orderBy, setSortBy, setOrderBy } =useSortedDirContext();@@ -117,9 +116,9 @@ function GridPerspective(props: Props) {if (!firstRender && actions && actions.length > 0) {for (const action of actions) {if (action.action === 'openNext') {- openNextFile();+ openNextFile(sortedDirContent);} else if (action.action === 'openPrevious') {- openPrevFile();+ openPrevFile(sortedDirContent);}}}@@ -199,10 +198,6 @@ function GridPerspective(props: Props) {}};- const openDeleteFileDialog = () => {- dispatch(AppActions.toggleDeleteMultipleEntriesDialog());- };-const openAddRemoveTagsDialog = () => {setIsAddRemoveTagsDialogOpened(true);};@@ -241,12 +236,12 @@ function GridPerspective(props: Props) {};const keyBindingHandlers = {- nextDocument: () => openNextFile(),- prevDocument: () => openPrevFile(),+ nextDocument: () => openNextFile(sortedDirContent),+ prevDocument: () => openPrevFile(sortedDirContent),selectAll: () => toggleSelectAllFiles(),deleteDocument: () => {if (fileOperationsEnabled(selectedEntries)) {- openDeleteFileDialog();+ openDeleteMultipleEntriesDialog();}},addRemoveTags: () => {@@ -432,7 +427,6 @@ function GridPerspective(props: Props) {mouseY={mouseY}open={Boolean(fileContextMenuAnchorEl)}onClose={() => setFileContextMenuAnchorEl(null)}- openDeleteFileDialog={openDeleteFileDialog}openRenameFileDialog={openRenameEntryDialog}openMoveCopyFilesDialog={openMoveCopyFilesDialog}openShareFilesDialog={openShareFilesDialog}diff --git a/src/renderer/perspectives/grid/components/MainToolbar.tsx b/src/renderer/perspectives/grid/components/MainToolbar.tsxindex 58b5dc7d1..a420a0de5 100644--- a/src/renderer/perspectives/grid/components/MainToolbar.tsx+++ b/src/renderer/perspectives/grid/components/MainToolbar.tsx@@ -51,6 +51,7 @@ import { useDirectoryContentContext } from '-/hooks/useDirectoryContentContext';import { useCurrentLocationContext } from '-/hooks/useCurrentLocationContext';import { useSelectedEntriesContext } from '-/hooks/useSelectedEntriesContext';import { usePerspectiveSettingsContext } from '-/hooks/usePerspectiveSettingsContext';+import { useDeleteMultipleEntriesDialogContext } from '-/components/dialogs/hooks/useDeleteMultipleEntriesDialogContext';interface Props {prefixDataTID?: string;@@ -86,6 +87,8 @@ function MainToolbar(props: Props) {const keyBindings = useSelector(getKeyBindingObject);const dispatch: AppDispatch = useDispatch();const { currentLocation, readOnlyMode } = useCurrentLocationContext();+ const { openDeleteMultipleEntriesDialog } =+ useDeleteMultipleEntriesDialogContext();function showProperties() {return openEntry(currentDirectoryPath, true);@@ -214,9 +217,7 @@ function MainToolbar(props: Props) {<IconButtonaria-label={t('core:deleteSelectedEntries')}data-tid={prefixDataTID + 'PerspectiveDeleteMultipleFiles'}- onClick={() =>- dispatch(AppActions.toggleDeleteMultipleEntriesDialog())- }+ onClick={() => openDeleteMultipleEntriesDialog()}// </span>size="large"><DeleteIcon />diff --git a/src/renderer/perspectives/list/components/MainContainer.tsx b/src/renderer/perspectives/list/components/MainContainer.tsxindex f7c061f8a..0d9c0882c 100644--- a/src/renderer/perspectives/list/components/MainContainer.tsx+++ b/src/renderer/perspectives/list/components/MainContainer.tsx@@ -17,7 +17,7 @@*/import React, { useEffect, useRef, useState } from 'react';-import { useSelector, useDispatch } from 'react-redux';+import { useSelector } from 'react-redux';import { GlobalHotKeys } from 'react-hotkeys';import { getDesktopMode, getKeyBindingObject } from '-/reducers/settings';import FileMenu from '-/components/menus/FileMenu';@@ -26,7 +26,6 @@ import EntryTagMenu from '-/components/menus/EntryTagMenu';import AddRemoveTagsDialog from '-/components/dialogs/AddRemoveTagsDialog';import MoveCopyFilesDialog from '-/components/dialogs/MoveCopyFilesDialog';import TagDropContainer from '-/components/TagDropContainer';-import { actions as AppActions, AppDispatch } from '-/reducers/app';import RowCell from '-/perspectives/list/components/RowCell';import MainToolbar from '-/perspectives/grid/components/MainToolbar';import SortingMenu from '-/perspectives/grid/components/SortingMenu';@@ -46,11 +45,11 @@ import { useDirectoryContentContext } from '-/hooks/useDirectoryContentContext';import { useSelectedEntriesContext } from '-/hooks/useSelectedEntriesContext';import { usePerspectiveSettingsContext } from '-/hooks/usePerspectiveSettingsContext';import { ListCellsStyleContextProvider } from '../hooks/ListCellsStyleProvider';-import { useRendererListenerContext } from '-/hooks/useRendererListenerContext';import { useIOActionsContext } from '-/hooks/useIOActionsContext';import { useCurrentLocationContext } from '-/hooks/useCurrentLocationContext';import { usePerspectiveActionsContext } from '-/hooks/usePerspectiveActionsContext';import useFirstRender from '-/utils/useFirstRender';+import { useDeleteMultipleEntriesDialogContext } from '-/components/dialogs/hooks/useDeleteMultipleEntriesDialogContext';interface Props {openRenameEntryDialog: () => void;@@ -59,14 +58,14 @@ interface Props {function ListPerspective(props: Props) {const { openRenameEntryDialog } = props;- const { openEntry } = useOpenedEntryContext();+ const { openEntry, openPrevFile, openNextFile } = useOpenedEntryContext();const { actions } = usePerspectiveActionsContext();- const { openPrevFile, openNextFile } = useRendererListenerContext();const { showDirectories } = usePerspectiveSettingsContext();const { currentLocation } = useCurrentLocationContext();const { openDirectory, currentDirectoryPath } = useDirectoryContentContext();const { openFileNatively, duplicateFile } = useIOActionsContext();- const dispatch: AppDispatch = useDispatch();+ const { openDeleteMultipleEntriesDialog } =+ useDeleteMultipleEntriesDialogContext();const { sortedDirContent, sortBy, orderBy, setSortBy, setOrderBy } =useSortedDirContext();@@ -117,9 +116,9 @@ function ListPerspective(props: Props) {if (!firstRender && actions && actions.length > 0) {for (const action of actions) {if (action.action === 'openNext') {- openNextFile();+ openNextFile(sortedDirContent);} else if (action.action === 'openPrevious') {- openPrevFile();+ openPrevFile(sortedDirContent);}}}@@ -199,10 +198,6 @@ function ListPerspective(props: Props) {}};- const openDeleteFileDialog = () => {- dispatch(AppActions.toggleDeleteMultipleEntriesDialog());- };-const openAddRemoveTagsDialog = () => {setIsAddRemoveTagsDialogOpened(true);};@@ -241,12 +236,12 @@ function ListPerspective(props: Props) {};const keyBindingHandlers = {- nextDocument: () => openNextFile(),- prevDocument: () => openPrevFile(),+ nextDocument: () => openNextFile(sortedDirContent),+ prevDocument: () => openPrevFile(sortedDirContent),selectAll: () => toggleSelectAllFiles(),deleteDocument: () => {if (fileOperationsEnabled(selectedEntries)) {- openDeleteFileDialog();+ openDeleteMultipleEntriesDialog();}},addRemoveTags: () => {@@ -432,7 +427,6 @@ function ListPerspective(props: Props) {mouseY={mouseY}open={Boolean(fileContextMenuAnchorEl)}onClose={() => setFileContextMenuAnchorEl(null)}- openDeleteFileDialog={openDeleteFileDialog}openRenameFileDialog={openRenameEntryDialog}openMoveCopyFilesDialog={openMoveCopyFilesDialog}openShareFilesDialog={openShareFilesDialog}diff --git a/src/renderer/reducers/app.ts b/src/renderer/reducers/app.tsindex 4a086549d..748feb0b2 100644--- a/src/renderer/reducers/app.ts+++ b/src/renderer/reducers/app.ts@@ -21,7 +21,6 @@ import { getURLParameter } from '-/utils/dom';import {isWorkerAvailable,loadExtensions,- mergeByProp,setGlobalShortcuts,setLanguage,} from '-/services/utils-io';@@ -29,12 +28,8 @@ import i18n from '../services/i18n';import {actions as SettingsActions,getCheckForUpdateOnStartup,- isFirstRun,isGlobalKeyBindingEnabled,} from '-/reducers/settings';-import { TS } from '-/tagspaces.namespace';-import { getProTeaserSlideIndex } from '-/content/ProTeaserSlides';-//import { extensionsFound } from '-/extension-config';import { ThunkDispatch } from 'redux-thunk';import { AnyAction } from 'redux';@@ -48,100 +43,17 @@ export const types = {PROGRESS: 'APP/PROGRESS',PROGRESS_FINISH: 'APP/PROGRESS_FINISH',RESET_PROGRESS: 'APP/RESET_PROGRESS',- //LAST_BACKGROUND_IMAGE_CHANGE: 'APP/LAST_BACKGROUND_IMAGE_CHANGE',- //LAST_BACKGROUND_COLOR_CHANGE: 'APP/LAST_BACKGROUND_COLOR_CHANGE',- //LAST_THUMBNAIL_IMAGE_CHANGE: 'APP/LAST_THUMBNAIL_IMAGE_CHANGE',- //OPEN_LINK: 'APP/OPEN_LINK',- LOGIN_SUCCESS: 'APP/LOGIN_SUCCESS',+ //LOGIN_SUCCESS: 'APP/LOGIN_SUCCESS',LOGIN_FAILURE: 'APP/LOGIN_FAILURE',LOGOUT: 'APP/LOGOUT',- // LOAD_DIRECTORY_SUCCESS: 'APP/LOAD_DIRECTORY_SUCCESS',SET_DIRECTORY_META: 'APP/SET_DIRECTORY_META',- //LOAD_DIRECTORY_FAILURE: 'APP/LOAD_DIRECTORY_FAILURE',- //CLEAR_DIRECTORY_CONTENT: 'APP/CLEAR_DIRECTORY_CONTENT',- // LOAD_PAGE_CONTENT: 'APP/LOAD_PAGE_CONTENT',- //SET_SEARCH_RESULTS: 'APP/SET_SEARCH_RESULTS',- //EXIT_SEARCH_MODE: 'APP/EXIT_SEARCH_MODE',- //ENTER_SEARCH_MODE: 'APP/ENTER_SEARCH_MODE',- //APPEND_SEARCH_RESULTS: 'APP/APPEND_SEARCH_RESULTS',SET_SEARCH_FILTER: 'APP/SET_SEARCH_FILTER',SET_NEW_VERSION_AVAILABLE: 'APP/SET_NEW_VERSION_AVAILABLE',SET_CURRENLOCATIONID: 'APP/SET_CURRENLOCATIONID',- //SET_LAST_SELECTED_ENTRY: 'APP/SET_LAST_SELECTED_ENTRY',- //SET_SELECTED_ENTRIES: 'APP/SET_SELECTED_ENTRIES',- //SET_TAG_LIBRARY_CHANGED: 'APP/SET_TAG_LIBRARY_CHANGED',SET_FILEDRAGGED: 'APP/SET_FILEDRAGGED',- TOGGLE_EDIT_TAG_DIALOG: 'APP/TOGGLE_EDIT_TAG_DIALOG',- TOGGLE_ABOUT_DIALOG: 'APP/TOGGLE_ABOUT_DIALOG',- TOGGLE_LOCATION_DIALOG: 'APP/TOGGLE_LOCATION_DIALOG',- TOGGLE_ONBOARDING_DIALOG: 'APP/TOGGLE_ONBOARDING_DIALOG',- TOGGLE_KEYBOARD_DIALOG: 'APP/TOGGLE_KEYBOARD_DIALOG',- TOGGLE_LICENSE_DIALOG: 'APP/TOGGLE_LICENSE_DIALOG',- TOGGLE_OPENLINK_DIALOG: 'APP/TOGGLE_OPENLINK_DIALOG',- TOGGLE_OPEN_PRO_TEASER_DIALOG: 'APP/TOGGLE_OPEN_PRO_TEASER_DIALOG',- TOGGLE_THIRD_PARTY_LIBS_DIALOG: 'APP/TOGGLE_THIRD_PARTY_LIBS_DIALOG',- TOGGLE_SETTINGS_DIALOG: 'APP/TOGGLE_SETTINGS_DIALOG',- TOGGLE_CREATE_DIRECTORY_DIALOG: 'APP/TOGGLE_CREATE_DIRECTORY_DIALOG',- TOGGLE_NEW_ENTRY_DIALOG: 'APP/TOGGLE_NEW_ENTRY_DIALOG',- TOGGLE_NEW_FILE_DIALOG: 'APP/TOGGLE_NEW_FILE_DIALOG',- TOGGLE_NEW_AUDIO_DIALOG: 'APP/TOGGLE_NEW_AUDIO_DIALOG',- TOGGLE_DELETE_MULTIPLE_ENTRIES_DIALOG:- 'APP/TOGGLE_DELETE_MULTIPLE_ENTRIES_DIALOG',- TOGGLE_IMPORT_KANBAN_DIALOG: 'APP/TOGGLE_IMPORT_KANBAN_DIALOG',- //TOGGLE_UPLOAD_DIALOG: 'APP/TOGGLE_UPLOAD_DIALOG',- TOGGLE_TRUNCATED_DIALOG: 'APP/TOGGLE_TRUNCATED_DIALOG',- //SET_CURRENT_DIRECTORY_DIRS: 'APP/SET_CURRENT_DIRECTORY_DIRS',- //CLEAR_UPLOAD_DIALOG: 'APP/CLEAR_UPLOAD_DIALOG',- TOGGLE_PROGRESS_DIALOG: 'APP/TOGGLE_PROGRESS_DIALOG',- OPEN_LOCATIONMANAGER_PANEL: 'APP/OPEN_LOCATIONMANAGER_PANEL',- OPEN_TAGLIBRARY_PANEL: 'APP/OPEN_TAGLIBRARY_PANEL',- OPEN_SEARCH_PANEL: 'APP/OPEN_SEARCH_PANEL',- OPEN_HELPFEEDBACK_PANEL: 'APP/OPEN_HELPFEEDBACK_PANEL',CLOSE_ALLVERTICAL_PANELS: 'APP/CLOSE_ALLVERTICAL_PANELS',- //REFLECT_DELETE_ENTRY: 'APP/REFLECT_DELETE_ENTRY',- //REFLECT_DELETE_ENTRIES: 'APP/REFLECT_DELETE_ENTRIES',- //REFLECT_RENAME_ENTRY: 'APP/REFLECT_RENAME_ENTRY',- //REFLECT_CREATE_ENTRY: 'APP/REFLECT_CREATE_ENTRY',- //REFLECT_CREATE_ENTRIES: 'APP/REFLECT_CREATE_ENTRIES',- // REFLECT_UPDATE_SIDECARTAGS: 'APP/REFLECT_UPDATE_SIDECARTAGS',- // REFLECT_UPDATE_SIDECARMETA: 'APP/REFLECT_UPDATE_SIDECARMETA',- //UPDATE_CURRENTDIR_ENTRY: 'APP/UPDATE_CURRENTDIR_ENTRY',- //UPDATE_CURRENTDIR_ENTRIES: 'APP/UPDATE_CURRENTDIR_ENTRIES',- //REFLECT_EDITED_ENTRY_PATHS: 'APP/REFLECT_EDITED_ENTRY_PATHS',- // SET_ISLOADING: 'APP/SET_ISLOADING',- //ADD_EXTENSIONS: 'APP/ADD_EXTENSIONS',- //REMOVE_EXTENSIONS: 'APP/REMOVE_EXTENSIONS',- //UPDATE_EXTENSION: 'APP/UPDATE_EXTENSION',};-/*export type OpenedEntry = {- uuid: string;- path: string;- url?: string;- size: number;- lmdt: number;- locationId?: string;- viewingExtensionPath: string;- viewingExtensionId: string;- editingExtensionPath?: string;- editingExtensionId?: string;- isFile?: boolean;- isAutoSaveEnabled?: boolean;- color?: string;- description?: string;- perspective?: TS.PerspectiveType;- editMode?: boolean;- // changed?: boolean;- /!**- * if its true iframe will be reloaded- * if its false && editMode==true and changed==true => show reload dialog- * default: undefined- *!/- shouldReload?: boolean;- focused?: boolean; // TODO make it mandatory once support for multiple files is added- tags?: Array<TS.Tag>;-};*/-let showLocations = true;let showTagLibrary = false;let showSearch = false;@@ -164,8 +76,6 @@ if (window.ExtDefaultVerticalPanel === 'none') {}export const initialState = {- //extensions: extensionsFound,- //isLoading: false,error: null,loggedIn: false,isOnline: false,@@ -173,13 +83,6 @@ export const initialState = {progress: [],isUpdateInProgress: false,isUpdateAvailable: false,- //currentLocationId: null,- //currentDirectoryPath: '',- //currentDirectoryColor: '',- //currentDirectoryDescription: '',- //currentDirectoryTags: [],- //currentDirectoryEntries: [],- //isReadOnlyMode: false,searchResults: [],notificationStatus: {visible: false,@@ -187,30 +90,13 @@ export const initialState = {notificationType: '',autohide: false,},- editTagDialogOpened: false,- aboutDialogOpened: false,- locationDialogOpened: false,- openLinkDialogOpened: false,- proTeaserIndex: -1,- onboardingDialogOpened: false,- keysDialogOpened: false,- isNewEntryDialogOpened: false,- isNewFileDialogOpened: false,- isNewAudioDialogOpened: false,- licenseDialogOpened: false,- thirdPartyLibsDialogOpened: false,- settingsDialogOpened: false,createDirectoryDialogOpened: null,- importKanBanDialogOpened: false,- // lastSelectedEntry: null,- //selectedEntries: [],tagLibraryChanged: false,isEntryInFullWidth: false,- //isGeneratingThumbs: false,- locationManagerPanelOpened: showLocations,+ //locationManagerPanelOpened: showLocations,tagLibraryPanelOpened: showTagLibrary,searchPanelOpened: showSearch,- user: window.ExtDemoUser+ /*user: window.ExtDemoUser? {attributes: window.ExtDemoUser,// eslint-disable-next-line @typescript-eslint/no-empty-function@@ -218,43 +104,16 @@ export const initialState = {// eslint-disable-next-line @typescript-eslint/no-empty-functionverifySoftwareToken: () => {},}- : undefined,+ : undefined,*/};// The state described here will not be persisted// eslint-disable-next-line default-param-lastexport default (state: any = initialState, action: any) => {switch (action.type) {- /*case types.LAST_BACKGROUND_IMAGE_CHANGE: {- return {- ...state,- lastBackgroundImageChange: {- folderPath: action.folderPath,- dt: action.lastBackgroundImageChange,- },- };- }- case types.LAST_BACKGROUND_COLOR_CHANGE: {- return {- ...state,- lastBackgroundColorChange: {- folderPath: action.folderPath,- dt: action.lastBackgroundColorChange,- },- };- }- case types.LAST_THUMBNAIL_IMAGE_CHANGE: {- return {- ...state,- lastThumbnailImageChange: {- thumbPath: action.thumbPath,- dt: action.lastThumbnailImageChange,- },- };- }*/- case types.LOGIN_SUCCESS: {+ /* case types.LOGIN_SUCCESS: {return { ...state, user: action.user };- }+ }*/case types.DEVICE_ONLINE: {return { ...state, isOnline: true, error: null };}@@ -305,32 +164,32 @@ export default (state: any = initialState, action: any) => {/*case types.SET_TAG_LIBRARY_CHANGED: {return { ...state, tagLibraryChanged: !state.tagLibraryChanged };}*/- case types.TOGGLE_EDIT_TAG_DIALOG: {+ /* case types.TOGGLE_EDIT_TAG_DIALOG: {return {...state,tag: action.tag,editTagDialogOpened: !state.editTagDialogOpened,};- }- case types.TOGGLE_ABOUT_DIALOG: {+ }*/+ /*case types.TOGGLE_ABOUT_DIALOG: {return { ...state, aboutDialogOpened: !state.aboutDialogOpened };- }- case types.TOGGLE_LOCATION_DIALOG: {+ }*/+ /*case types.TOGGLE_LOCATION_DIALOG: {return { ...state, locationDialogOpened: !state.locationDialogOpened };- }- case types.TOGGLE_ONBOARDING_DIALOG: {+ }*/+ /*case types.TOGGLE_ONBOARDING_DIALOG: {return {...state,onboardingDialogOpened: !state.onboardingDialogOpened,};- }- case types.TOGGLE_OPENLINK_DIALOG: {+ }*/+ /*case types.TOGGLE_OPENLINK_DIALOG: {return {...state,openLinkDialogOpened: !state.openLinkDialogOpened,};- }- case types.TOGGLE_OPEN_PRO_TEASER_DIALOG: {+ }*/+ /*case types.TOGGLE_OPEN_PRO_TEASER_DIALOG: {let index = -1;const proTeaserIndex = getProTeaserSlideIndex(action.proTeaserPage);if (proTeaserIndex && proTeaserIndex > -1) {@@ -342,61 +201,61 @@ export default (state: any = initialState, action: any) => {...state,proTeaserIndex: index,};- }- case types.TOGGLE_KEYBOARD_DIALOG: {+ }*/+ /*case types.TOGGLE_KEYBOARD_DIALOG: {return { ...state, keysDialogOpened: !state.keysDialogOpened };- }- case types.TOGGLE_NEW_ENTRY_DIALOG: {+ }*/+ /*case types.TOGGLE_NEW_ENTRY_DIALOG: {return {...state,isNewEntryDialogOpened: !state.isNewEntryDialogOpened,};- }- case types.TOGGLE_NEW_FILE_DIALOG: {+ }*/+ /*case types.TOGGLE_NEW_FILE_DIALOG: {return {...state,isNewFileDialogOpened: !state.isNewFileDialogOpened,};- }- case types.TOGGLE_NEW_AUDIO_DIALOG: {+ }*/+ /*case types.TOGGLE_NEW_AUDIO_DIALOG: {return {...state,isNewAudioDialogOpened: !state.isNewAudioDialogOpened,};- }- case types.TOGGLE_DELETE_MULTIPLE_ENTRIES_DIALOG: {+ }*/+ /*case types.TOGGLE_DELETE_MULTIPLE_ENTRIES_DIALOG: {return {...state,deleteMultipleEntriesDialogOpened:!state.deleteMultipleEntriesDialogOpened,};- }- case types.TOGGLE_IMPORT_KANBAN_DIALOG: {+ }*/+ /*case types.TOGGLE_IMPORT_KANBAN_DIALOG: {return {...state,importKanBanDialogOpened: !state.importKanBanDialogOpened,};- }- case types.TOGGLE_LICENSE_DIALOG: {+ }*/+ /*case types.TOGGLE_LICENSE_DIALOG: {return { ...state, licenseDialogOpened: !state.licenseDialogOpened };- }- case types.TOGGLE_THIRD_PARTY_LIBS_DIALOG: {+ }*/+ /*case types.TOGGLE_THIRD_PARTY_LIBS_DIALOG: {return {...state,thirdPartyLibsDialogOpened: !state.thirdPartyLibsDialogOpened,};- }- case types.TOGGLE_SETTINGS_DIALOG: {+ }*/+ /*case types.TOGGLE_SETTINGS_DIALOG: {return { ...state, settingsDialogOpened: !state.settingsDialogOpened };- }- case types.TOGGLE_CREATE_DIRECTORY_DIALOG: {+ }*/+ /*case types.TOGGLE_CREATE_DIRECTORY_DIALOG: {// dialog closed = nullreturn {...state,createDirectoryDialogOpened:state.createDirectoryDialogOpened !== null ? null : action.props,};- }+ }*//*case types.TOGGLE_UPLOAD_DIALOG: {// if (PlatformIO.haveObjectStoreSupport()) {// upload dialog have objectStore support only@@ -409,12 +268,12 @@ export default (state: any = initialState, action: any) => {//}// return state;}*/- case types.TOGGLE_TRUNCATED_DIALOG: {+ /*case types.TOGGLE_TRUNCATED_DIALOG: {return {...state,isTruncatedConfirmDialogOpened: !state.isTruncatedConfirmDialogOpened,};- }+ }*//* case types.SET_CURRENT_DIRECTORY_DIRS: {if (JSON.stringify(state.currentDirectoryDirs) !==@@ -438,80 +297,19 @@ export default (state: any = initialState, action: any) => {// }// return state;}*/- case types.TOGGLE_PROGRESS_DIALOG: {+ /*case types.TOGGLE_PROGRESS_DIALOG: {return {...state,progressDialogOpened: !state.progressDialogOpened,};- }+ }*/case types.SET_SEARCH_FILTER: {return {...state,searchFilter: action.searchFilter,};}- /*case types.REFLECT_DELETE_ENTRY: {- const editedEntryPaths = [{ action: 'delete', path: action.path }];- return {- ...state,- editedEntryPaths,- };- }- case types.REFLECT_DELETE_ENTRIES: {- const editedEntryPaths = action.paths.map((path) => ({- action: 'delete',- path: path,- }));- return {- ...state,- editedEntryPaths,- };- }*/- /*case types.REFLECT_CREATE_ENTRY: {- const newEntry: TS.FileSystemEntry = action.newEntry;- const editedEntryPaths: Array<TS.EditedEntryPath> = [- {- action: newEntry.isFile ? 'createFile' : 'createDir',- path: newEntry.path,- uuid: newEntry.uuid,- },- ];- return {- ...state,- editedEntryPaths,- };- }*/- /*case types.REFLECT_CREATE_ENTRIES: {- const editedEntryPaths: Array<TS.EditedEntryPath> = action.fsEntries.map(- (newEntry) => ({- action: newEntry.isFile ? 'createFile' : 'createDir',- path: newEntry.path,- uuid: newEntry.uuid,- }),- );- return {- ...state,- editedEntryPaths,- };- }*/- /*case types.REFLECT_RENAME_ENTRY: {- const editedEntryPaths = [- { action: 'rename', path: action.path },- { action: 'rename', path: action.newPath },- ];-- return {- ...state,- editedEntryPaths,- };- }*/- /*case types.REFLECT_EDITED_ENTRY_PATHS: {- return {- ...state,- editedEntryPaths: action.editedEntryPaths, // .map(path => ({ action: 'edit', path }))- };- }*/- case types.OPEN_LOCATIONMANAGER_PANEL: {+ /*case types.OPEN_LOCATIONMANAGER_PANEL: {return {...state,locationManagerPanelOpened: true,@@ -546,7 +344,7 @@ export default (state: any = initialState, action: any) => {searchPanelOpened: false,helpFeedbackPanelOpened: true,};- }+ }*//*case types.ADD_EXTENSIONS: {const extensions = mergeByProp(state.extensions,@@ -644,7 +442,7 @@ export const actions = {thumbPath,lastThumbnailImageChange: lastThumbnailImageChange || new Date().getTime(),}),*/- loggedIn: (user) => ({ type: types.LOGIN_SUCCESS, user }),+ //loggedIn: (user) => ({ type: types.LOGIN_SUCCESS, user }),/*openLink: (url: string, options = { fullWidth: true }) => ({type: types.OPEN_LINK,url,@@ -652,16 +450,6 @@ export const actions = {}),*/initApp: () => (dispatch: (action) => void, getState: () => any) => {disableBackGestureMac();- // migrate TagLibrary from redux state- /*const { taglibrary } = getState();- if (taglibrary && taglibrary.length > 0) {- try {- setTagLibrary(taglibrary);- dispatch(tagLibraryActions.deleteAll());- } catch (e) {- console.log('migrate TagLibrary failed', e);- }- }*/dispatch(SettingsActions.setZoomRestoreApp());dispatch(SettingsActions.upgradeSettings()); // TODO call this only on app version update@@ -669,10 +457,10 @@ export const actions = {if (getCheckForUpdateOnStartup(state)) {dispatch(SettingsActions.checkForUpdate());}- if (isFirstRun(state)) {+ /*if (isFirstRun(state)) {dispatch(actions.toggleOnboardingDialog());dispatch(actions.toggleLicenseDialog());- }+ }*/setTimeout(() => {setGlobalShortcuts(isGlobalKeyBindingEnabled(state));loadExtensions();@@ -694,38 +482,6 @@ export const actions = {? console.log('Worker is available in renderer thread'): console.log('Worker is not available in renderer thread'),);-- // let openDefaultLocation = true;- /*const lid = getURLParameter('tslid');- const dPath = getURLParameter('tsdpath');- const ePath = getURLParameter('tsepath');- const cmdOpen = getURLParameter('cmdopen');- if (lid || dPath || ePath) {- // openDefaultLocation = false;- setTimeout(() => {- // todo move this in OpenEntryContextProvider -> useEffect- dispatch(actions.openLink(window.location.href));- }, 1000);- } else if (cmdOpen) {- // openDefaultLocation = false;- setTimeout(() => {- dispatch(- actions.openLink(- // window.location.href.split('?')[0] +- 'ts://?cmdopen=' + cmdOpen,- { fullWidth: true }- )- );- }, 1000);- }*/- /*const defaultLocationId = getDefaultLocationId(state);- if (- openDefaultLocation &&- defaultLocationId &&- defaultLocationId.length > 0- ) {- dispatch(actions.openLocationById(defaultLocationId));- }*/},goOnline: () => ({ type: types.DEVICE_ONLINE }),goOffline: () => ({ type: types.DEVICE_OFFLINE }),@@ -757,74 +513,53 @@ export const actions = {actions.setProgress(progress.key, progressPercentage, abort, fileName),);},- showCreateDirectoryDialog:+ /*showCreateDirectoryDialog:() => (dispatch: (action) => void, getState: () => any) => {- /* const { app } = getState();- if (!app.currentDirectoryPath) {- dispatch(- actions.showNotification(- i18n.t('core:firstOpenaFolder'),- 'warning',- true- )- );- } else {*/dispatch(actions.toggleCreateDirectoryDialog());- //}- },- showCreateFileDialog:+ },*/+ /*showCreateFileDialog:() => (dispatch: (action) => void, getState: () => any) => {- /*const { app } = getState();- if (!app.currentDirectoryPath) {- dispatch(- actions.showNotification(- i18n.t('core:firstOpenaFolder'),- 'warning',- true- )- );- } else {*/+dispatch(actions.toggleNewEntryDialog());- // }- },- toggleEditTagDialog: (tag: TS.Tag) => ({+ },*/+ /*toggleEditTagDialog: (tag: TS.Tag) => ({type: types.TOGGLE_EDIT_TAG_DIALOG,tag,- }),- toggleAboutDialog: () => ({ type: types.TOGGLE_ABOUT_DIALOG }),- toggleLocationDialog: () => ({ type: types.TOGGLE_LOCATION_DIALOG }),- toggleOnboardingDialog: () => ({ type: types.TOGGLE_ONBOARDING_DIALOG }),- toggleKeysDialog: () => ({ type: types.TOGGLE_KEYBOARD_DIALOG }),- toggleOpenLinkDialog: () => ({ type: types.TOGGLE_OPENLINK_DIALOG }),- toggleProTeaser: (slidePage?: string) => ({+ }),*/+ //toggleAboutDialog: () => ({ type: types.TOGGLE_ABOUT_DIALOG }),+ //toggleLocationDialog: () => ({ type: types.TOGGLE_LOCATION_DIALOG }),+ //toggleOnboardingDialog: () => ({ type: types.TOGGLE_ONBOARDING_DIALOG }),+ //toggleKeysDialog: () => ({ type: types.TOGGLE_KEYBOARD_DIALOG }),+ //toggleOpenLinkDialog: () => ({ type: types.TOGGLE_OPENLINK_DIALOG }),+ /*toggleProTeaser: (slidePage?: string) => ({type: types.TOGGLE_OPEN_PRO_TEASER_DIALOG,proTeaserPage: slidePage,- }),- toggleLicenseDialog: () => ({ type: types.TOGGLE_LICENSE_DIALOG }),- toggleThirdPartyLibsDialog: () => ({+ }),*/+ //toggleLicenseDialog: () => ({ type: types.TOGGLE_LICENSE_DIALOG }),+ /* toggleThirdPartyLibsDialog: () => ({type: types.TOGGLE_THIRD_PARTY_LIBS_DIALOG,- }),- toggleSettingsDialog: () => ({ type: types.TOGGLE_SETTINGS_DIALOG }),- toggleCreateDirectoryDialog: (props = undefined) => ({+ }),*/+ //toggleSettingsDialog: () => ({ type: types.TOGGLE_SETTINGS_DIALOG }),+ /*toggleCreateDirectoryDialog: (props = undefined) => ({type: types.TOGGLE_CREATE_DIRECTORY_DIALOG,props,- }),- toggleNewEntryDialog: () => ({ type: types.TOGGLE_NEW_ENTRY_DIALOG }),- toggleNewFileDialog: () => ({ type: types.TOGGLE_NEW_FILE_DIALOG }),- toggleNewAudioDialog: () => ({ type: types.TOGGLE_NEW_AUDIO_DIALOG }),- toggleDeleteMultipleEntriesDialog: () => ({+ }),*/+ //toggleNewEntryDialog: () => ({ type: types.TOGGLE_NEW_ENTRY_DIALOG }),+ //toggleNewFileDialog: () => ({ type: types.TOGGLE_NEW_FILE_DIALOG }),+ //toggleNewAudioDialog: () => ({ type: types.TOGGLE_NEW_AUDIO_DIALOG }),+ /*toggleDeleteMultipleEntriesDialog: () => ({type: types.TOGGLE_DELETE_MULTIPLE_ENTRIES_DIALOG,- }),- toggleImportKanBanDialog: () => ({+ }),*/+ /*toggleImportKanBanDialog: () => ({type: types.TOGGLE_IMPORT_KANBAN_DIALOG,- }),+ }),*//*toggleUploadDialog: (title = '') => ({type: types.TOGGLE_UPLOAD_DIALOG,title,}),*/- toggleTruncatedConfirmDialog: () => ({+ /*toggleTruncatedConfirmDialog: () => ({type: types.TOGGLE_TRUNCATED_DIALOG,- }),+ }),*//*setCurrentDirectoryDirs: dirs => ({type: types.SET_CURRENT_DIRECTORY_DIRS,dirs@@ -832,13 +567,13 @@ export const actions = {/*clearUploadDialog: () => ({type: types.CLEAR_UPLOAD_DIALOG,}),*/- toggleProgressDialog: () => ({+ /*toggleProgressDialog: () => ({type: types.TOGGLE_PROGRESS_DIALOG,- }),- openLocationManagerPanel: () => ({ type: types.OPEN_LOCATIONMANAGER_PANEL }),+ }),*/+ /*openLocationManagerPanel: () => ({ type: types.OPEN_LOCATIONMANAGER_PANEL }),openTagLibraryPanel: () => ({ type: types.OPEN_TAGLIBRARY_PANEL }),openSearchPanel: () => ({ type: types.OPEN_SEARCH_PANEL }),- openHelpFeedbackPanel: () => ({ type: types.OPEN_HELPFEEDBACK_PANEL }),+ openHelpFeedbackPanel: () => ({ type: types.OPEN_HELPFEEDBACK_PANEL }),*//*setSelectedEntries: (selectedEntries: Array<TS.FileSystemEntry>) => (dispatch: (action) => void) => {@@ -951,7 +686,7 @@ export const getLastBackgroundColorChange = (state: any) =>state.app.lastBackgroundColorChange;export const getLastThumbnailImageChange = (state: any) =>state.app.lastThumbnailImageChange;*/-export const currentUser = (state: any) => state.app.user;+//export const currentUser = (state: any) => state.app.user;//export const getEditedEntryPaths = (state: any) => state.app.editedEntryPaths;/*export const getCurrentDirectoryColor = (state: any) =>state.app.currentDirectoryColor;@@ -977,7 +712,7 @@ export const getLastSelectedEntryPath = (state: any) => {}return undefined;};*/-export const getSelectedTag = (state: any) => state.app.tag;+//export const getSelectedTag = (state: any) => state.app.tag;export const isTagLibraryChanged = (state: any) => state.app.tagLibraryChanged;/*export const getSelectedEntries = (state: any) =>state.app.selectedEntries ? state.app.selectedEntries : [];*/@@ -987,54 +722,54 @@ export const isTagLibraryChanged = (state: any) => state.app.tagLibraryChanged;// export const getDirectoryMeta = (state: any) => state.app.directoryMeta;// export const isGeneratingThumbs = (state: any) => state.app.isGeneratingThumbs;// export const isReadOnlyMode = (state: any) => state.app.isReadOnlyMode;-export const isOnboardingDialogOpened = (state: any) =>- state.app.onboardingDialogOpened;-export const isEditTagDialogOpened = (state: any) =>- state.app.editTagDialogOpened;-export const isAboutDialogOpened = (state: any) => state.app.aboutDialogOpened;-export const isLocationDialogOpened = (state: any) =>- state.app.locationDialogOpened;-export const isKeysDialogOpened = (state: any) => state.app.keysDialogOpened;-export const isLicenseDialogOpened = (state: any) =>- state.app.licenseDialogOpened;-export const isThirdPartyLibsDialogOpened = (state: any) =>- state.app.thirdPartyLibsDialogOpened;-export const isSettingsDialogOpened = (state: any) =>- state.app.settingsDialogOpened;-export const isCreateDirectoryOpened = (state: any) =>- state.app.createDirectoryDialogOpened;-export const isNewEntryDialogOpened = (state: any) =>- state.app.isNewEntryDialogOpened;-export const isNewFileDialogOpened = (state: any) =>- state.app.isNewFileDialogOpened;-export const isNewAudioDialogOpened = (state: any) =>- state.app.isNewAudioDialogOpened;-export const isDeleteMultipleEntriesDialogOpened = (state: any) =>- state.app.deleteMultipleEntriesDialogOpened;-export const isImportKanBanDialogOpened = (state: any) =>- state.app.importKanBanDialogOpened;+/*export const isOnboardingDialogOpened = (state: any) =>+ state.app.onboardingDialogOpened;*/+/*export const isEditTagDialogOpened = (state: any) =>+ state.app.editTagDialogOpened;*/+//export const isAboutDialogOpened = (state: any) => state.app.aboutDialogOpened;+/*export const isLocationDialogOpened = (state: any) =>+ state.app.locationDialogOpened;*/+//export const isKeysDialogOpened = (state: any) => state.app.keysDialogOpened;+/*export const isLicenseDialogOpened = (state: any) =>+ state.app.licenseDialogOpened;*/+/*export const isThirdPartyLibsDialogOpened = (state: any) =>+ state.app.thirdPartyLibsDialogOpened;*/+/*export const isSettingsDialogOpened = (state: any) =>+ state.app.settingsDialogOpened;*/+/*export const isCreateDirectoryOpened = (state: any) =>+ state.app.createDirectoryDialogOpened;*/+/*export const isNewEntryDialogOpened = (state: any) =>+ state.app.isNewEntryDialogOpened;*/+/*export const isNewFileDialogOpened = (state: any) =>+ state.app.isNewFileDialogOpened;*/+/*export const isNewAudioDialogOpened = (state: any) =>+ state.app.isNewAudioDialogOpened;*/+/*export const isDeleteMultipleEntriesDialogOpened = (state: any) =>+ state.app.deleteMultipleEntriesDialogOpened;*/+/*export const isImportKanBanDialogOpened = (state: any) =>+ state.app.importKanBanDialogOpened;*//*export const isUploadDialogOpened = (state: any) =>state.app.uploadDialogOpened;*/-export const isTruncatedConfirmDialogOpened = (state: any) =>- state.app.isTruncatedConfirmDialogOpened;-export const isOpenLinkDialogOpened = (state: any) =>- state.app.openLinkDialogOpened;-export const isProTeaserVisible = (state: any) => state.app.proTeaserIndex > -1;-export const getProTeaserIndex = (state: any) => state.app.proTeaserIndex;-export const isProgressOpened = (state: any) => state.app.progressDialogOpened;+/*export const isTruncatedConfirmDialogOpened = (state: any) =>+ state.app.isTruncatedConfirmDialogOpened;*/+/*export const isOpenLinkDialogOpened = (state: any) =>+ state.app.openLinkDialogOpened;*/+//export const isProTeaserVisible = (state: any) => state.app.proTeaserIndex > -1;+//export const getProTeaserIndex = (state: any) => state.app.proTeaserIndex;+//export const isProgressOpened = (state: any) => state.app.progressDialogOpened;//export const getOpenLink = (state: any) => state.app.openLink;export const getNotificationStatus = (state: any) =>state.app.notificationStatus;//export const getCurrentLocationId = (state: any) => state.app.currentLocationId;export const isEntryInFullWidth = (state: any) => state.app.isEntryInFullWidth;//export const isLoading = (state: any) => state.app.isLoading;-export const isLocationManagerPanelOpened = (state: any) =>- state.app.locationManagerPanelOpened;-export const isTagLibraryPanelOpened = (state: any) =>+/*export const isLocationManagerPanelOpened = (state: any) =>+ state.app.locationManagerPanelOpened;*/+/*export const isTagLibraryPanelOpened = (state: any) =>state.app.tagLibraryPanelOpened;export const isSearchPanelOpened = (state: any) => state.app.searchPanelOpened;export const isHelpFeedbackPanelOpened = (state: any) =>- state.app.helpFeedbackPanelOpened;+ state.app.helpFeedbackPanelOpened;*//*export const getLastSearchTimestamp = (state: any) =>state.app.lastSearchTimestamp;*///export const isSearchMode = (state: any) => state.app.searchMode;diff --git a/src/renderer/tagspaces.namespace.d.ts b/src/renderer/tagspaces.namespace.d.tsindex a1f4481b6..0153ee4b7 100644--- a/src/renderer/tagspaces.namespace.d.ts+++ b/src/renderer/tagspaces.namespace.d.ts@@ -219,7 +219,7 @@ export namespace TS {viewingExtensionId: string;editingExtensionPath?: string;editingExtensionId?: string;- editMode?: boolean; // TODO move in DescriptionContextProvider+ //editMode?: boolean; // TODO move in FilePropertiesContextProviderfocused?: boolean; // TODO make it mandatory once support for multiple files is added}@@ -258,6 +258,11 @@ export namespace TS {openItem: (item: TS.HistoryItem) => void;};+ type KanBanImportDialogContextData = {+ openKanBanImportDialog: () => void;+ closeKanBanImportDialog: () => void;+ };+interface EditedEntryPath {action: EditedEntryAction;path: string;diff --git a/src/renderer/utils/HandleAuth.tsx b/src/renderer/utils/HandleAuth.tsxindex cf2b76cf5..b920ec70e 100644--- a/src/renderer/utils/HandleAuth.tsx+++ b/src/renderer/utils/HandleAuth.tsx@@ -10,11 +10,13 @@ import { useDispatch } from 'react-redux';import { actions as AppActions, AppDispatch } from '-/reducers/app';import { useCurrentLocationContext } from '-/hooks/useCurrentLocationContext';import { useTaggingActionsContext } from '-/hooks/useTaggingActionsContext';+import { useUserContext } from '-/hooks/useUserContext';function HandleAuth() {const username = useRef(undefined);const { addLocations } = useCurrentLocationContext();const { importTagGroups } = useTaggingActionsContext();+ const { loggedIn } = useUserContext();const dispatch: AppDispatch = useDispatch();React.useEffect(() => {@@ -53,10 +55,10 @@ function HandleAuth() {}// @ts-ignoreusername.current = authData.username;- dispatch(AppActions.loggedIn(authData));+ loggedIn(authData);} else if (nextAuthState === AuthState.SignedOut) {username.current = undefined;- dispatch(AppActions.loggedIn(undefined));+ loggedIn(undefined);}});}, []);diff --git a/tests/e2e/folderprops.pw.e2e.js b/tests/e2e/folderprops.pw.e2e.jsindex edcf66da2..aaa5ab104 100644--- a/tests/e2e/folderprops.pw.e2e.js+++ b/tests/e2e/folderprops.pw.e2e.js@@ -227,8 +227,8 @@ test.describe('TST02 - Folder properties', () => {);expect(clipboardContent.length > 0).toBe(true);*///await setInputKeys('directoryName', clipboardContent);- await setInputValue('[data-tid=directoryName] input', sharingLinkValue);- await clickOn('[data-tid=directoryName] input');+ await setInputValue('[data-tid=openLinkTID] input', sharingLinkValue);+ await clickOn('[data-tid=openLinkTID] input');await clickOn('[data-tid=confirmOpenLink]');await expectElementExist('[data-tid=currentDir_empty_folder]', true, 5000);/*diff --git a/tests/e2e/perspective-grid-right-button.pw.e2e.js b/tests/e2e/perspective-grid-right-button.pw.e2e.jsindex 6cbb7938b..ac8694314 100644--- a/tests/e2e/perspective-grid-right-button.pw.e2e.js+++ b/tests/e2e/perspective-grid-right-button.pw.e2e.js@@ -183,8 +183,8 @@ test.describe('TST50** - Right button on a file', () => {}); */await clickOn('[data-tid=tagMoreButton_' + testTagName + ']');await clickOn('[data-tid=editTagDialogMenu]');- await global.client.dblclick('[data-tid=editTagEntryDialog_input] input');- await setInputKeys('editTagEntryDialog_input', testTagName + 'Edited');+ //await global.client.dblclick('[data-tid=editTagEntryDialog_input] input');+ await setInputKeys('editTagEntryDialog_input', 'Edited');await clickOn('[data-tid=confirmEditTagEntryDialog]');// await waitForNotification();diff --git a/tests/e2e/tag.pw.e2e.js b/tests/e2e/tag.pw.e2e.jsindex 9d4149ff7..e2e94c915 100644--- a/tests/e2e/tag.pw.e2e.js+++ b/tests/e2e/tag.pw.e2e.js@@ -1,5 +1,6 @@/* Copyright (c) 2016-present - TagSpaces UG (Haftungsbeschraenkt). All rights reserved. */import { expect, test } from '@playwright/test';+import { formatDateTime4Tag } from '@tagspaces/tagspaces-common/misc';import {checkSettings,clickOn,@@ -29,6 +30,7 @@ import {testGroup,testTagName,} from './tag.helpers';+import { dataTidFormat } from '../../src/renderer/services/test';test.beforeAll(async () => {await startTestingApp('extconfig.js');@@ -310,4 +312,31 @@ test.describe('TST04 - Testing the tag library:', () => {'[data-tid=tagGroupContainer_' + destinationTagGroup + ']',);});++ test('TST0422 - Add custom date smarttag [web,electron]', async () => {+ const tagName = 'custom-date';+ const sourceTagGroup = 'Smart Tags';++ await clickOn('[data-tid=locationManager]');+ await clickOn('[data-tid=location_' + defaultLocationName + ']');+ await clickOn('[data-tid=tagLibrary]');+ await expectElementExist(+ '[data-tid=tagContainer_' + tagName + ']',+ true,+ 3000,+ '[data-tid=tagGroupContainer_' + dataTidFormat(sourceTagGroup) + ']',+ );+ await dnd(+ '[data-tid=tagContainer_' + tagName + ']',+ getGridFileSelector('sample.txt'),+ );+ await clickOn('[data-tid=confirmEditTagEntryDialog]');++ await expectElementExist(+ '[data-tid=tagContainer_' + formatDateTime4Tag(new Date(), true) + ']',+ true,+ 8000,+ '[data-tid=perspectiveGridFileTable]',+ );+ });});