mirror of
https://github.com/LemmyNet/lemmy-ui.git
synced 2024-11-29 07:41:13 +00:00
Fetching site data first to get UserService / my_user. Fixes #66
This commit is contained in:
parent
2a4581e9ba
commit
d05001cb13
1 changed files with 6 additions and 8 deletions
|
@ -10,7 +10,7 @@ import { IsoData } from '../shared/interfaces';
|
|||
import { routes } from '../shared/routes';
|
||||
import IsomorphicCookie from 'isomorphic-cookie';
|
||||
import { lemmyHttp, setAuth } from '../shared/utils';
|
||||
import { GetSiteForm, GetSiteResponse } from 'lemmy-js-client';
|
||||
import { GetSiteForm } from 'lemmy-js-client';
|
||||
import process from 'process';
|
||||
import { Helmet } from 'inferno-helmet';
|
||||
import { initializeSite } from '../shared/initialize';
|
||||
|
@ -34,15 +34,15 @@ server.get('/*', async (req, res) => {
|
|||
|
||||
let promises: Promise<any>[] = [];
|
||||
|
||||
let siteData = lemmyHttp.getSite(getSiteForm);
|
||||
promises.push(siteData);
|
||||
// Get site data first
|
||||
let site = await lemmyHttp.getSite(getSiteForm);
|
||||
initializeSite(site);
|
||||
|
||||
if (activeRoute.fetchInitialData) {
|
||||
promises.push(...activeRoute.fetchInitialData(auth, req.path));
|
||||
}
|
||||
|
||||
let resolver = await Promise.all(promises);
|
||||
let site: GetSiteResponse = resolver[0];
|
||||
let routeData = resolver.slice(1, resolver.length);
|
||||
let routeData = await Promise.all(promises);
|
||||
|
||||
// Redirect to the 404 if there's an API error
|
||||
if (routeData[0] && routeData[0].error) {
|
||||
|
@ -66,8 +66,6 @@ server.get('/*', async (req, res) => {
|
|||
lang,
|
||||
};
|
||||
|
||||
initializeSite(site);
|
||||
|
||||
const wrapper = (
|
||||
<StaticRouter location={req.url} context={isoData}>
|
||||
<App site={isoData.site} />
|
||||
|
|
Loading…
Reference in a new issue