Fix editor title when not logged in

This commit is contained in:
apple502j 2020-04-11 01:30:29 +09:00
parent d8df31587e
commit 93f9eaf718
2 changed files with 18 additions and 5 deletions

View file

@ -1,14 +1,23 @@
const React = require('react');
const Helmet = require('react-helmet').default;
const PropTypes = require('prop-types');
const projectShape = require('./projectshape.jsx').projectShape;
const Meta = props => {
const {id, title, instructions, author} = props.projectInfo;
// Do not want to render any meta tags unless all the info is loaded
// Check only author (object) because it is ok to have empty string instructions
if (!author) return null;
if (!author) {
// Project info is not ready. It's either fetching state, or logged-out users creating project.
if (!props.userPresent) {
return (
<Helmet>
<title>Scratch - Imagine, Program, Share</title>
</Helmet>
);
}
return null;
}
const truncatedInstructions = instructions.split(' ')
.slice(0, 50)
@ -38,7 +47,8 @@ const Meta = props => {
};
Meta.propTypes = {
projectInfo: projectShape
projectInfo: projectShape,
userPresent: PropTypes.bool
};
module.exports = Meta;

View file

@ -700,7 +700,10 @@ class Preview extends React.Component {
return (
<React.Fragment>
<Meta projectInfo={this.props.projectInfo} />
<Meta
projectInfo={this.props.projectInfo}
userPresent={this.props.userPresent}
/>
{this.props.playerMode ?
<Page
className={classNames({