mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-02-02 22:26:57 +01:00
Experiment some Suspense
This splits code, lazy load the other less-critical components
This commit is contained in:
parent
c578b41105
commit
4a9cae9cb6
1 changed files with 17 additions and 4 deletions
21
src/app.jsx
21
src/app.jsx
|
@ -1,6 +1,7 @@
|
||||||
import './app.css';
|
import './app.css';
|
||||||
|
|
||||||
import debounce from 'just-debounce-it';
|
import debounce from 'just-debounce-it';
|
||||||
|
import { lazy, Suspense } from 'preact/compat';
|
||||||
import {
|
import {
|
||||||
useEffect,
|
useEffect,
|
||||||
useLayoutEffect,
|
useLayoutEffect,
|
||||||
|
@ -17,14 +18,14 @@ import ComposeButton from './components/compose-button';
|
||||||
import { ICONS } from './components/ICONS';
|
import { ICONS } from './components/ICONS';
|
||||||
import KeyboardShortcutsHelp from './components/keyboard-shortcuts-help';
|
import KeyboardShortcutsHelp from './components/keyboard-shortcuts-help';
|
||||||
import Loader from './components/loader';
|
import Loader from './components/loader';
|
||||||
import Modals from './components/modals';
|
// import Modals from './components/modals';
|
||||||
import NotificationService from './components/notification-service';
|
import NotificationService from './components/notification-service';
|
||||||
import SearchCommand from './components/search-command';
|
import SearchCommand from './components/search-command';
|
||||||
import Shortcuts from './components/shortcuts';
|
import Shortcuts from './components/shortcuts';
|
||||||
import NotFound from './pages/404';
|
import NotFound from './pages/404';
|
||||||
import AccountStatuses from './pages/account-statuses';
|
import AccountStatuses from './pages/account-statuses';
|
||||||
import Bookmarks from './pages/bookmarks';
|
import Bookmarks from './pages/bookmarks';
|
||||||
import Catchup from './pages/catchup';
|
// import Catchup from './pages/catchup';
|
||||||
import Favourites from './pages/favourites';
|
import Favourites from './pages/favourites';
|
||||||
import FollowedHashtags from './pages/followed-hashtags';
|
import FollowedHashtags from './pages/followed-hashtags';
|
||||||
import Following from './pages/following';
|
import Following from './pages/following';
|
||||||
|
@ -55,6 +56,9 @@ import store from './utils/store';
|
||||||
import { getCurrentAccount } from './utils/store-utils';
|
import { getCurrentAccount } from './utils/store-utils';
|
||||||
import './utils/toast-alert';
|
import './utils/toast-alert';
|
||||||
|
|
||||||
|
const Catchup = lazy(() => import('./pages/catchup'));
|
||||||
|
const Modals = lazy(() => import('./components/modals'));
|
||||||
|
|
||||||
window.__STATES__ = states;
|
window.__STATES__ = states;
|
||||||
window.__STATES_STATS__ = () => {
|
window.__STATES_STATS__ = () => {
|
||||||
const keys = [
|
const keys = [
|
||||||
|
@ -382,7 +386,9 @@ function App() {
|
||||||
)}
|
)}
|
||||||
{isLoggedIn && <ComposeButton />}
|
{isLoggedIn && <ComposeButton />}
|
||||||
{isLoggedIn && <Shortcuts />}
|
{isLoggedIn && <Shortcuts />}
|
||||||
<Modals />
|
<Suspense>
|
||||||
|
<Modals />
|
||||||
|
</Suspense>
|
||||||
{isLoggedIn && <NotificationService />}
|
{isLoggedIn && <NotificationService />}
|
||||||
<BackgroundService isLoggedIn={isLoggedIn} />
|
<BackgroundService isLoggedIn={isLoggedIn} />
|
||||||
{uiState !== 'loading' && <SearchCommand onClose={focusDeck} />}
|
{uiState !== 'loading' && <SearchCommand onClose={focusDeck} />}
|
||||||
|
@ -458,7 +464,14 @@ function SecondaryRoutes({ isLoggedIn }) {
|
||||||
<Route path=":id" element={<List />} />
|
<Route path=":id" element={<List />} />
|
||||||
</Route>
|
</Route>
|
||||||
<Route path="/ft" element={<FollowedHashtags />} />
|
<Route path="/ft" element={<FollowedHashtags />} />
|
||||||
<Route path="/catchup" element={<Catchup />} />
|
<Route
|
||||||
|
path="/catchup"
|
||||||
|
element={
|
||||||
|
<Suspense>
|
||||||
|
<Catchup />
|
||||||
|
</Suspense>
|
||||||
|
}
|
||||||
|
/>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
<Route path="/:instance?/t/:hashtag" element={<Hashtag />} />
|
<Route path="/:instance?/t/:hashtag" element={<Hashtag />} />
|
||||||
|
|
Loading…
Reference in a new issue