Commit 93f9eaf7 authored by apple502j's avatar apple502j

Fix editor title when not logged in

parent d8df3158
const React = require('react'); const React = require('react');
const Helmet = require('react-helmet').default; const Helmet = require('react-helmet').default;
const PropTypes = require('prop-types');
const projectShape = require('./projectshape.jsx').projectShape; const projectShape = require('./projectshape.jsx').projectShape;
const Meta = props => { const Meta = props => {
const {id, title, instructions, author} = props.projectInfo; const {id, title, instructions, author} = props.projectInfo;
// Do not want to render any meta tags unless all the info is loaded if (!author) {
// Check only author (object) because it is ok to have empty string instructions // Project info is not ready. It's either fetching state, or logged-out users creating project.
if (!author) return null; if (!props.userPresent) {
return (
<Helmet>
<title>Scratch - Imagine, Program, Share</title>
</Helmet>
);
}
return null;
}
const truncatedInstructions = instructions.split(' ') const truncatedInstructions = instructions.split(' ')
.slice(0, 50) .slice(0, 50)
...@@ -38,7 +47,8 @@ const Meta = props => { ...@@ -38,7 +47,8 @@ const Meta = props => {
}; };
Meta.propTypes = { Meta.propTypes = {
projectInfo: projectShape projectInfo: projectShape,
userPresent: PropTypes.bool
}; };
module.exports = Meta; module.exports = Meta;
...@@ -700,7 +700,10 @@ class Preview extends React.Component { ...@@ -700,7 +700,10 @@ class Preview extends React.Component {
return ( return (
<React.Fragment> <React.Fragment>
<Meta projectInfo={this.props.projectInfo} /> <Meta
projectInfo={this.props.projectInfo}
userPresent={this.props.userPresent}
/>
{this.props.playerMode ? {this.props.playerMode ?
<Page <Page
className={classNames({ className={classNames({
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment