TagSpaces is an offline, open source, document manager with tagging support
chore: optimizations
Ilian Sapundshiev6a9ce92c33e8
diff --git a/app/components/HelpFeedbackPanel.tsx b/app/components/HelpFeedbackPanel.tsxindex 585b065c2..55c0a24a0 100644--- a/app/components/HelpFeedbackPanel.tsx+++ b/app/components/HelpFeedbackPanel.tsx@@ -41,13 +41,12 @@ import styles from '-/components/SidePanels.css';import i18n from '-/services/i18n';import { KeyShortcutsIcon, HelpIcon } from '-/components/CommonIcons';import Links from '-/content/links';-import { connect } from 'react-redux';-import { getCurrentLanguage } from '-/reducers/settings';import { Pro } from '-/pro';interface Props {classes?: any;theme?: any;+ language: string;openURLExternally: (url: string, skipConfirmation?: boolean) => void;toggleAboutDialog?: () => void;toggleKeysDialog: () => void;@@ -97,7 +96,6 @@ function HelpFeedbackPanel(props: Props) {}}><ListItem- buttononClick={toggleAboutDialog}title="Opens the about dialog"data-tid="aboutDialog"@@ -110,7 +108,6 @@ function HelpFeedbackPanel(props: Props) {</Typography></ListItem><ListItem- buttononClick={() =>openURLExternally(Links.documentationLinks.general, true)}@@ -122,7 +119,7 @@ function HelpFeedbackPanel(props: Props) {{i18n.t('core:documentation')}</Typography></ListItem>- <ListItem button onClick={toggleKeysDialog}>+ <ListItem onClick={toggleKeysDialog}><ListItemIcon><KeyShortcutsIcon /></ListItemIcon>@@ -131,7 +128,6 @@ function HelpFeedbackPanel(props: Props) {</Typography></ListItem><ListItem- buttononClick={() => openURLExternally(Links.links.changelogURL, true)}title="Opens the changelog of the app">@@ -142,7 +138,7 @@ function HelpFeedbackPanel(props: Props) {{i18n.t('core:whatsNew')}</Typography></ListItem>- <ListItem button onClick={toggleOnboardingDialog}>+ <ListItem onClick={toggleOnboardingDialog}><ListItemIcon><OnboardingIcon /></ListItemIcon>@@ -151,7 +147,6 @@ function HelpFeedbackPanel(props: Props) {</Typography></ListItem><ListItem- buttononClick={() => openURLExternally(Links.links.webClipper, true)}><ListItemIcon>@@ -163,7 +158,6 @@ function HelpFeedbackPanel(props: Props) {</ListItem><Divider /><ListItem- buttononClick={() => openURLExternally(Links.links.suggestFeature, true)}><ListItemIcon>@@ -174,7 +168,6 @@ function HelpFeedbackPanel(props: Props) {</Typography></ListItem><ListItem- buttononClick={() => openURLExternally(Links.links.forumsUrl, true)}><ListItemIcon>@@ -185,7 +178,6 @@ function HelpFeedbackPanel(props: Props) {</Typography></ListItem><ListItem- buttononClick={() => openURLExternally(Links.links.reportIssue, true)}><ListItemIcon>@@ -196,7 +188,6 @@ function HelpFeedbackPanel(props: Props) {</Typography></ListItem><ListItem- buttononClick={() => openURLExternally(Links.links.helpTranslating, true)}><ListItemIcon>@@ -208,7 +199,6 @@ function HelpFeedbackPanel(props: Props) {</ListItem><Divider /><ListItem- buttononClick={() => openURLExternally(Links.links.emailContact, true)}><ListItemIcon>@@ -220,7 +210,6 @@ function HelpFeedbackPanel(props: Props) {</ListItem>{Pro && (<ListItem- buttononClick={() =>openURLExternally(Links.links.cancelSubscription, true)}@@ -233,10 +222,7 @@ function HelpFeedbackPanel(props: Props) {</Typography></ListItem>)}- <ListItem- button- onClick={() => openURLExternally(Links.links.twitter, true)}- >+ <ListItem onClick={() => openURLExternally(Links.links.twitter, true)}><ListItemIcon><TwitterIcon /></ListItemIcon>@@ -245,7 +231,7 @@ function HelpFeedbackPanel(props: Props) {</Typography></ListItem><Divider />- <ListItem button onClick={() => toggleProTeaser()}>+ <ListItem onClick={() => toggleProTeaser()}><ListItemIcon><ProTeaserIcon /></ListItemIcon>@@ -258,9 +244,4 @@ function HelpFeedbackPanel(props: Props) {);}-function mapStateToProps(state) {- return { language: getCurrentLanguage(state) };-}-export default connect(mapStateToProps)(- withStyles(styles, { withTheme: true })(HelpFeedbackPanel)-);+export default withStyles(styles, { withTheme: true })(HelpFeedbackPanel);diff --git a/app/components/LoadingAnimation.tsx b/app/components/LoadingAnimation.tsxindex 921dffe3c..89dd52d33 100644--- a/app/components/LoadingAnimation.tsx+++ b/app/components/LoadingAnimation.tsx@@ -17,18 +17,18 @@*/import React from 'react';-import { connect } from 'react-redux';+import { useSelector } from 'react-redux';import withStyles from '@mui/styles/withStyles';import PlatformIO from '-/services/platform-facade';import { isLoading } from '-/reducers/app';interface Props {theme: any;- loading: boolean;}function LoadingAnimation(props: Props) {- const { theme, loading } = props;+ const { theme } = props;+ const loading = useSelector(isLoading);if (!loading ||@@ -49,8 +49,6 @@ function LoadingAnimation(props: Props) {alignItems: 'center',borderRadius: 10,backdropFilter: 'grayscale(1)'- // backdropFilter: 'blur(2px)',- // backgroundColor: '#fafafa33' // red: '#eb585882' '#d9d9d980'}}><div className="lds-ellipsis">@@ -63,17 +61,6 @@ function LoadingAnimation(props: Props) {);}-function mapStateToProps(state) {- return {- loading: isLoading(state)- };-}--const areEqual = (prevProp: Props, nextProp: Props) =>- nextProp.loading === prevProp.loading;--export default connect(mapStateToProps)(- withStyles(undefined, { withTheme: true })(- React.memo(LoadingAnimation, areEqual)- )+export default withStyles(undefined, { withTheme: true })(+ React.memo(LoadingAnimation));diff --git a/app/components/MobileNavigation.tsx b/app/components/MobileNavigation.tsxindex 795a2149f..bfde45409 100644--- a/app/components/MobileNavigation.tsx+++ b/app/components/MobileNavigation.tsx@@ -72,6 +72,7 @@ const styles: any = (theme: any) => ({interface Props {classes: any;+ language: string;toggleProTeaser: (slidePage?: string) => void;toggleOnboardingDialog: () => void;toggleCreateFileDialog: () => void;@@ -125,7 +126,8 @@ function MobileNavigation(props: Props) {width,theme,switchTheme,- user+ user,+ language} = props;return (<Box@@ -209,6 +211,7 @@ function MobileNavigation(props: Props) {{props.isSearchPanelOpened && <StoredSearches reduceHeightBy={170} />}{props.isHelpFeedbackPanelOpened && (<HelpFeedbackPanel+ language={language}reduceHeightBy={170}openURLExternally={openURLExternally}toggleAboutDialog={toggleAboutDialog}@@ -378,7 +381,6 @@ function mapActionCreatorsToProps(dispatch) {openHelpFeedbackPanel: AppActions.openHelpFeedbackPanel,openURLExternally: AppActions.openURLExternally,showNotification: AppActions.showNotification,- // closeAllVerticalPanels: AppActions.closeAllVerticalPanels,switchTheme: SettingsActions.switchTheme},dispatchdiff --git a/app/containers/App.tsx b/app/containers/App.tsxindex 2e37124c5..35fa6ba06 100644--- a/app/containers/App.tsx+++ b/app/containers/App.tsx@@ -17,7 +17,7 @@*/import React from 'react';-import { connect } from 'react-redux';+import { useSelector } from 'react-redux';import { I18nextProvider } from 'react-i18next'; // as we build ourself via webpackimport {createTheme,@@ -124,34 +124,18 @@ const draculaTheme = createTheme({}});-// const lightBlueTheme = createMuiTheme({-// palette: {-// mode: 'light', // Switching the dark mode on is a single property value change.-// primary: {-// light: '#cbe9fa',-// main: '#19aeff',-// dark: '#19aeff',-// contrastText: '#ffffff',-// },-// secondary: {-// main: '#19aeff',-// },-// divider: '#ddd'-// // secondary: { main: '#cccccc', 200: '#ddd' }-// }-// });-interface Props {children: Object;- currentTheme: string;- defaultRegularTheme: string;- defaultDarkTheme: string;}function App(props: Props) {let theme = legacyTheme;let regularTheme = legacyTheme;let darkTheme = darklegacyTheme;- const { currentTheme, defaultRegularTheme, defaultDarkTheme } = props;++ const currentTheme = useSelector(getCurrentTheme);+ const defaultDarkTheme = useSelector(getDefaultDarkTheme);+ const defaultRegularTheme = useSelector(getDefaultRegularTheme);+const systemDarkMode = useMediaQuery('(prefers-color-scheme: dark)'); // window.matchMedia().matches;switch (defaultRegularTheme) {case 'legacy': {@@ -201,11 +185,4 @@ function App(props: Props) {);}-function mapStateToProps(state) {- return {- currentTheme: getCurrentTheme(state),- defaultDarkTheme: getDefaultDarkTheme(state),- defaultRegularTheme: getDefaultRegularTheme(state)- };-}-export default connect(mapStateToProps)(App);+export default App;