2
1
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2023-12-13 21:00:40 +01:00

Updated loading state to kick in earlier

refs https://github.com/TryGhost/Team/issues/1692

- Moved Loading component to App (so it shows as a placeholder)
- Disabled loading settings from the API (not used for now), to speed up loading
This commit is contained in:
Simon Backx 2022-07-20 11:01:30 +02:00
parent 2657af11f6
commit 4a4db114f0
5 changed files with 12 additions and 18 deletions

View file

@ -8,6 +8,7 @@ import {hasMode} from './utils/check-mode';
import setupGhostApi from './utils/api';
import CommentsBox from './components/CommentsBox';
import {useEffect} from 'react';
import Loading from './components/Loading';
function AuthFrame({adminUrl, onLoad, initStatus}) {
useEffect(function () {
@ -26,12 +27,9 @@ function AuthFrame({adminUrl, onLoad, initStatus}) {
}
function CommentsBoxContainer({done, appVersion}) {
if (!done) {
return null;
}
return (
<ShadowRoot appVersion={appVersion}>
<CommentsBox />
{done ? <CommentsBox /> : <Loading />}
</ShadowRoot>
);
}

View file

@ -1,7 +1,6 @@
import React, {useContext} from 'react';
import AppContext from '../AppContext';
import NotSignedInBox from './NotSignedInBox';
import Loading from './Loading';
import Form from './Form';
import Comment from './Comment';
import Pagination from './Pagination';
@ -57,16 +56,12 @@ const CommentsBox = (props) => {
return (
<section className={'ghost-display ' + containerClass} style={style}>
<Pagination />
{comments ?
<>
<div className={!pagination ? 'mt-4' : ''}>
{commentsElements}
</div>
<div>
{ member ? (isPaidMember || !paidOnly ? <Form commentsCount={commentsCount} avatarSaturation={props.avatarSaturation} /> : <NotPaidBox />) : <NotSignedInBox /> }
</div>
</>
: <Loading />}
<div className={!pagination ? 'mt-4' : ''}>
{commentsElements}
</div>
<div>
{ member ? (isPaidMember || !paidOnly ? <Form commentsCount={commentsCount} avatarSaturation={props.avatarSaturation} /> : <NotPaidBox />) : <NotSignedInBox /> }
</div>
</section>
);
};

View file

@ -3,7 +3,7 @@ import {ReactComponent as SpinnerIcon} from '../images/icons/spinner.svg';
function Loading() {
return (
<div class="flex items-center justify-center w-full h-36">
<div className="ghost-display flex items-center justify-center w-full h-36">
<SpinnerIcon className="w-12 h-12 mb-6 fill-[rgba(0,0,0,0.3)] dark:fill-[rgba(255,255,255,0.6)]" />
</div>
);

View file

@ -203,7 +203,8 @@ function setupGhostApi({siteUrl = window.location.origin, apiUrl, apiKey}) {
let settings = {};
try {
settings = await api.site.settings();
// for now we don't need to fetch all the settings (the ones we need are passed via the script tag data attributes)
//settings = await api.site.settings();
site = {
...settings
};

View file

@ -109,6 +109,6 @@ export function getBundledCssLink({appVersion}) {
if (process.env.NODE_ENV === 'production' && appVersion) {
return `https://unpkg.com/@tryghost/comments-ui@~${appVersion}/umd/main.css`;
} else {
return 'https://comments.localhost/main.css';
return 'http://localhost:4000/main.css';
}
}