Skip to content

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

lazyloading the onboarding dialog

Ilian Sapundshiev1a7af04abb57
diff --git a/.gitignore b/.gitignore
index 8b1686fe6..a6b35a6d4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -80,4 +80,5 @@ web/third-party.txt
app/extconfig.js
app/extconfig1.js
web/extconfig.js
+web/extconfig1.js
cordova/www/extconfig.js
diff --git a/app/components/LoadingLazy.js b/app/components/LoadingLazy.js
new file mode 100644
index 000000000..b6ff08bb5
--- /dev/null
+++ b/app/components/LoadingLazy.js
@@ -0,0 +1,25 @@
+/**
+ * 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/>.
+ *
+ * @flow
+ */
+
+import React from 'react';
+import Typography from '@material-ui/core/Typography';
+import i18n from '../services/i18n';
+
+const LoadingLazy = () => (<Typography style={{ padding: 10 }}>{i18n.t('core:loading')}</Typography>);
+export default LoadingLazy;
diff --git a/app/containers/MainPage.js b/app/containers/MainPage.js
index a2c7c7d69..ebc406415 100644
--- a/app/containers/MainPage.js
+++ b/app/containers/MainPage.js
@@ -36,7 +36,6 @@ import { DragDropContext } from 'react-dnd';
import VerticalNavigation, {
AppVerticalPanels
} from '../components/VerticalNavigation';
-import OnboardingDialog from '../components/dialogs/OnboardingDialog';
import FolderContainer from '../components/FolderContainer';
import EntryContainer from '../components/EntryContainer';
import {
@@ -68,6 +67,14 @@ import AppConfig from '../config';
import buildDesktopMenu from '../services/electron-menus';
import buildTrayIconMenu from '../services/electron-tray-menu';
import i18n from '../services/i18n';
+import LoadingLazy from '../components/LoadingLazy';
+
+const OnboardingDialog = React.lazy(() => import(/* webpackChunkName: "OnboardingDialog" */ '../components/dialogs/OnboardingDialog'));
+const OnboardingDialogAsync = props => (
+ <React.Suspense fallback={<LoadingLazy />}>
+ <OnboardingDialog {...props} />
+ </React.Suspense>
+);
const initialSplitSize = 44;
const drawerWidth = 300;
@@ -537,10 +544,12 @@ class MainPage extends Component<Props, State> {
</Button>,
]}
/>
- <OnboardingDialog
- open={this.props.isFirstRun}
- onClose={this.toggleOnboarding}
- />
+ {this.props.isFirstRun && (
+ <OnboardingDialogAsync
+ open={this.props.isFirstRun}
+ onClose={this.toggleOnboarding}
+ />
+ )}
</TargetFileBox>
</HotKeys>
);