Skip to content
This repository was archived by the owner on Oct 11, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion hyperion/renderer/browser-shim.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,3 @@ global.navigator = {
global.CSS = {
escape: require('css.escape'),
};
global.IS_SERVER = true;
101 changes: 0 additions & 101 deletions src/helpers/p-queue.js

This file was deleted.

42 changes: 0 additions & 42 deletions src/routes.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// @flow
import * as React from 'react';
import compose from 'recompose/compose';
import PromiseQueue from './helpers/p-queue';
import { Route, Switch, Redirect } from 'react-router';
import styled, { ThemeProvider } from 'styled-components';
import Loadable from 'react-loadable';
Expand Down Expand Up @@ -154,47 +153,6 @@ const ComposerFallback = signedOutFallback(Composer, () => (
<Login redirectPath={`${CLIENT_URL}/new/thread`} />
));

// On the client, preload the important routes when browser is idle and users has been using the app
// for > 5s (i.e. all the data should hopefully have been loaded)
if (!global || global.IS_SERVER !== true) {
const preload = [
FullscreenThreadView,
CommunityView,
CommunityLoginView,
UserView,
ChannelView,
Dashboard,
Notifications,
];

requestAnimationFrame(() => {
// Fallback to setTimeout for older browsers with no requestIdleCallback support
const idle = window.requestIdleCallback || window.setTimeout;
const queue = new PromiseQueue({
concurrency: 2,
});
idle(() => {
// Wait 5 seconds to make sure the data has loaded
setTimeout(() => {
preload.forEach(bundle => {
queue
.add(() => {
return new Promise(res => {
idle(() => {
bundle
.preload()
.then(res)
.catch(err => console.error(err));
});
});
})
.catch(err => console.error(err));
});
}, 5000);
});
});
}

type Props = {
currentUser: ?GetUserType,
isLoadingCurrentUser: boolean,
Expand Down