Skip to content

TagSpaces is an offline, open source, document manager with tagging support

chore: performance optimizations

Ilian Sapundshievfa6598da51e3
diff --git a/app/components/EntryProperties.tsx b/app/components/EntryProperties.tsx
index 190affa2a..e43fb6678 100644
--- a/app/components/EntryProperties.tsx
+++ b/app/components/EntryProperties.tsx
@@ -23,7 +23,6 @@ import React, {
useRef,
useState
} from 'react';
-import { useStateWithCallbackLazy } from 'use-state-with-callback';
import { getBgndFileLocationForDirectory } from '@tagspaces/tagspaces-common/paths';
import L from 'leaflet';
import { Theme } from '@mui/material/styles';
@@ -40,7 +39,6 @@ import Tooltip from '-/components/Tooltip';
import LocationIcon from '@mui/icons-material/WorkOutline';
import EditIcon from '@mui/icons-material/Edit';
import CloudLocationIcon from '@mui/icons-material/CloudQueue';
-import MenuItem from '@mui/material/MenuItem';
import Stack from '@mui/material/Stack';
import SetBackgroundIcon from '@mui/icons-material/OpacityOutlined';
import ClearBackgroundIcon from '@mui/icons-material/FormatColorResetOutlined';
@@ -80,6 +78,7 @@ import PlatformIO from '../services/platform-facade';
import TagsSelect from './TagsSelect';
import TransparentBackground from './TransparentBackground';
import { getThumbnailURLPromise } from '-/services/thumbsgenerator';
+import { getCurrentLanguage } from '-/reducers/settings';
import {
getLastBackgroundImageChange,
getLastThumbnailImageChange,
@@ -165,6 +164,7 @@ const styles: any = (theme: any) => ({
interface Props {
classes: any;
theme: any;
+ language: string;
openedEntry: OpenedEntry;
renameFile: (path: string, nextPath: string) => Promise<boolean>;
renameDirectory: (path: string, nextPath: string) => Promise<boolean>;
@@ -613,7 +613,7 @@ function EntryProperties(props: Props) {
});
};
- const { classes, isReadOnlyMode, theme, sharingLink } = props;
+ const { classes, isReadOnlyMode, theme, sharingLink, language } = props;
if (
!currentEntry ||
@@ -880,7 +880,7 @@ function EntryProperties(props: Props) {
url={props.tileServer.serverURL}
/>
) : (
- <NoTileServer />
+ <NoTileServer language={language} />
)}
<LayerGroup>
<Marker
@@ -1161,6 +1161,7 @@ function EntryProperties(props: Props) {
{!currentEntry.current.isFile && (
<Grid item xs={12} style={{ marginTop: 10 }}>
<PerspectiveSelector
+ language={language}
onChange={changePerspective}
defaultValue={perspectiveDefault}
label={i18n.t('core:choosePerspective')}
@@ -1477,7 +1478,8 @@ const ThumbnailTextField = withStyles((theme: Theme) =>
function mapStateToProps(state) {
return {
lastBackgroundImageChange: getLastBackgroundImageChange(state),
- lastThumbnailImageChange: getLastThumbnailImageChange(state)
+ lastThumbnailImageChange: getLastThumbnailImageChange(state),
+ language: getCurrentLanguage(state)
};
}
diff --git a/app/components/FolderContainer.tsx b/app/components/FolderContainer.tsx
index 9d17d1056..92d2c7747 100644
--- a/app/components/FolderContainer.tsx
+++ b/app/components/FolderContainer.tsx
@@ -279,6 +279,7 @@ function FolderContainer(props: Props) {
const {
currentDirectoryPath = '',
+ language,
loadDirectoryContent,
directoryContent,
classes,
@@ -605,6 +606,7 @@ function FolderContainer(props: Props) {
)}
{/* {isDesktopMode && <LocationMenu />} */}
<PathBreadcrumbs
+ language={language}
currentDirectoryPath={currentDirectoryPath}
currentLocationPath={currentLocationPath}
loadDirectoryContent={loadDirectoryContent}
diff --git a/app/components/NoTileServer.tsx b/app/components/NoTileServer.tsx
index f9bdf92d1..189839107 100644
--- a/app/components/NoTileServer.tsx
+++ b/app/components/NoTileServer.tsx
@@ -1,9 +1,11 @@
import React from 'react';
import i18n from '-/services/i18n';
-import { connect } from 'react-redux';
-import { getCurrentLanguage } from '-/reducers/settings';
-function NoTileServer() {
+interface Props {
+ language: string;
+}
+
+function NoTileServer(props: Props) {
return (
<div style={{ textAlign: 'center' }}>
<h1>{i18n.t('core:noTileServersTitle')}</h1>
@@ -12,8 +14,4 @@ function NoTileServer() {
);
}
-function mapStateToProps(state) {
- return { language: getCurrentLanguage(state) };
-}
-
-export default connect(mapStateToProps)(NoTileServer);
+export default NoTileServer;
diff --git a/app/components/PathBreadcrumbs.tsx b/app/components/PathBreadcrumbs.tsx
index a340c7381..bb381b35b 100644
--- a/app/components/PathBreadcrumbs.tsx
+++ b/app/components/PathBreadcrumbs.tsx
@@ -31,8 +31,6 @@ import {
import i18n from '../services/i18n';
import DirectoryMenu from './menus/DirectoryMenu';
import { TS } from '-/tagspaces.namespace';
-import { connect } from 'react-redux';
-import { getCurrentLanguage } from '-/reducers/settings';
// @ts-ignore
const StyledBreadcrumb = withStyles((theme: Theme) => ({
@@ -61,6 +59,7 @@ interface Props {
generateThumbnails: boolean,
loadDirMeta?: boolean
) => void;
+ language: string;
switchPerspective: (perspectiveId: string) => void;
setSelectedEntries: (selectedEntries: Array<Object>) => void;
openDirectory: () => void;
@@ -84,7 +83,6 @@ function PathBreadcrumbs(props: Props) {
currentDirectoryPath,
currentLocationPath,
loadDirectoryContent,
- switchPerspective,
setSelectedEntries,
openDirectory,
reflectCreateEntry,
@@ -214,12 +212,9 @@ function PathBreadcrumbs(props: Props) {
openDirectory={openDirectory}
reflectCreateEntry={reflectCreateEntry}
openFsEntry={openFsEntry}
- /*openAddRemoveTagsDialog={openAddRemoveTagsDialog}*/
/>
</>
);
}
-function mapStateToProps(state) {
- return { language: getCurrentLanguage(state) };
-}
-export default connect(mapStateToProps)(PathBreadcrumbs);
+
+export default PathBreadcrumbs;
diff --git a/app/components/PerspectiveSelector.tsx b/app/components/PerspectiveSelector.tsx
index b017a1401..a62ea5d6c 100644
--- a/app/components/PerspectiveSelector.tsx
+++ b/app/components/PerspectiveSelector.tsx
@@ -17,7 +17,6 @@
*/
import React from 'react';
-import Input from '@mui/material/Input';
import ListItemIcon from '@mui/material/ListItemIcon';
import LayersClearIcon from '@mui/icons-material/LayersClear';
import ListItemText from '@mui/material/ListItemText';
@@ -26,11 +25,17 @@ import MenuItem from '@mui/material/MenuItem';
import { AvailablePerspectives, PerspectiveIDs } from '-/perspectives';
import i18n from '../services/i18n';
import { Pro } from '-/pro';
-import { connect } from 'react-redux';
-import { getCurrentLanguage } from '-/reducers/settings';
import { BetaLabel, ProLabel } from '-/components/HelperComponents';
-function PerspectiveSelector(props) {
+interface Props {
+ language: string;
+ defaultValue: string;
+ onChange: (event: any) => void;
+ testId: string;
+ label?: string;
+}
+
+function PerspectiveSelector(props: Props) {
const { defaultValue, onChange, testId, label } = props;
const perspectiveSelectorMenuItems = [];
@@ -86,7 +91,4 @@ function PerspectiveSelector(props) {
);
}
-function mapStateToProps(state) {
- return { language: getCurrentLanguage(state) };
-}
-export default connect(mapStateToProps)(PerspectiveSelector);
+export default PerspectiveSelector;
diff --git a/app/components/dialogs/EditEntryTagDialog.tsx b/app/components/dialogs/EditEntryTagDialog.tsx
index 2c40cb279..94c333631 100644
--- a/app/components/dialogs/EditEntryTagDialog.tsx
+++ b/app/components/dialogs/EditEntryTagDialog.tsx
@@ -44,7 +44,7 @@ import TaggingActions from '-/reducers/tagging-actions';
import { isDateTimeTag } from '-/utils/dates';
import { TS } from '-/tagspaces.namespace';
import useValidation from '-/utils/useValidation';
-import { getMapTileServer } from '-/reducers/settings';
+import { getMapTileServer, getCurrentLanguage } from '-/reducers/settings';
import DialogCloseButton from '-/components/dialogs/DialogCloseButton';
import useTheme from '@mui/styles/useTheme';
import useMediaQuery from '@mui/material/useMediaQuery';
@@ -59,6 +59,7 @@ const styles = () => ({
interface Props {
classes: any;
+ language: string;
open: boolean;
onClose: () => void;
editTagForEntry: (path: string, tag: TS.Tag, title: string) => void;
@@ -98,7 +99,7 @@ function EditEntryTagDialog(props: Props) {
isShowDatePeriodEditor
);
const { setError, haveError } = useValidation();
- const { onClose, open } = props;
+ const { onClose, open, language } = props;
useEffect(() => {
if (titleRef && titleRef.current) {
@@ -178,6 +179,7 @@ function EditEntryTagDialog(props: Props) {
</FormControl>
{showGeoEditor && (
<GeoTagEditor
+ language={language}
geoTag={title}
onChange={setTitle}
// zoom={title === defaultTagLocation ? 2 : undefined} TODO defaultTagLocation can be in MGRS format
@@ -261,9 +263,6 @@ function EditEntryTagDialog(props: Props) {
function mapStateToProps(state) {
return {
selectedTag: getSelectedTag(state),
- /* currentEntryPath: getSelectedTag(state)
- ? getSelectedTag(state).path
- : undefined, */
selectedEntries: getSelectedEntries(state),
tileServer: getMapTileServer(state),
geoTaggingFormat: state.settings.geoTaggingFormat
diff --git a/app/components/dialogs/settings/SettingsGeneral.tsx b/app/components/dialogs/settings/SettingsGeneral.tsx
index 841e66602..37571900b 100644
--- a/app/components/dialogs/settings/SettingsGeneral.tsx
+++ b/app/components/dialogs/settings/SettingsGeneral.tsx
@@ -40,6 +40,7 @@ import i18n from '-/services/i18n';
import {
actions as SettingsActions,
getPersistTagsInSidecarFile,
+ getCurrentLanguage,
getSettings
} from '-/reducers/settings';
import ColorPickerDialog from '-/components/dialogs/ColorPickerDialog';
@@ -71,6 +72,7 @@ interface Props {
setTagTextColor: (tagTextColor: string) => void;
classes: any;
settings: any;
+ language: string;
persistTagsInSidecarFile: boolean;
toggleShowUnixHiddenEntries: () => void;
setCurrentTheme: (theme: string) => void;
@@ -124,7 +126,7 @@ function SettingsGeneral(props: Props) {
defaultPerspective = props.settings.defaultPerspective;
}
- const { classes, persistTagsInSidecarFile } = props;
+ const { classes, persistTagsInSidecarFile, language } = props;
return (
<List className={classes.root}>
@@ -200,6 +202,7 @@ function SettingsGeneral(props: Props) {
<ListItem className={classes.listItem}>
<ListItemText primary={i18n.t('Default Perspective')} />
<PerspectiveSelector
+ language={language}
onChange={changePerspective}
defaultValue={defaultPerspective}
testId="changePerspectiveInSettingsTID"
@@ -428,6 +431,7 @@ function SettingsGeneral(props: Props) {
function mapStateToProps(state) {
return {
settings: getSettings(state),
+ language: getCurrentLanguage(state),
persistTagsInSidecarFile: getPersistTagsInSidecarFile(state)
};
}