Skip to content

Commit bd4d247

Browse files
authored
Thank you chatgpt
1 parent 2e1a969 commit bd4d247

1 file changed

Lines changed: 38 additions & 44 deletions

File tree

src/playground/render-interface.jsx

Lines changed: 38 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,9 @@ class Interface extends React.Component {
164164
...props
165165
} = this.props;
166166

167-
// Check if the URL contains 'credits' and 'instructions' parameters
167+
// Get URL params and check for 'project_url'
168168
const urlParams = new URLSearchParams(window.location.search);
169+
const hasProjectUrl = urlParams.has('project_url');
169170
const description = {
170171
instructions: urlParams.has('instructions') ? urlParams.get('instructions') : 'No instructions provided.',
171172
credits: urlParams.has('credits') ? urlParams.get('credits') : 'No credits provided.'
@@ -174,6 +175,22 @@ class Interface extends React.Component {
174175
const isHomepage = isPlayerOnly && !isFullScreen;
175176
const isEditor = !isPlayerOnly;
176177

178+
// If project_url is not in URL, show default description (CodeSnap alpha stage message)
179+
const descriptionMessage = hasProjectUrl ? null : (
180+
<div className={styles.section}>
181+
<p>
182+
<FormattedMessage
183+
defaultMessage="{APP_NAME} is a more powerful Scratch modification that lets you create complex projects easily. Try it out by clicking See Inside!"
184+
id="tw.home.ampdescription"
185+
values={{ APP_NAME }}
186+
/>
187+
</p>
188+
</div>
189+
);
190+
191+
// Hide share button if no username in localStorage or if there is a 'project_url'
192+
const showShareButton = localStorage.getItem('username') && !hasProjectUrl;
193+
177194
return (
178195
<div className={classNames(styles.container, {
179196
[styles.playerOnly]: isHomepage,
@@ -199,16 +216,18 @@ class Interface extends React.Component {
199216
}}
200217
/>
201218
</div>
202-
<button
203-
onClick={this.handleShareProject}
204-
className={styles.shareButton}
205-
>
206-
<FormattedMessage
207-
defaultMessage="Share"
208-
description="Share button"
209-
id="tw.shareButton"
210-
/>
211-
</button>
219+
{showShareButton && (
220+
<button
221+
onClick={this.handleShareProject}
222+
className={styles.shareButton}
223+
>
224+
<FormattedMessage
225+
defaultMessage="Share"
226+
description="Share button"
227+
id="tw.shareButton"
228+
/>
229+
</button>
230+
)}
212231
</div>
213232
</div>
214233

@@ -225,46 +244,21 @@ class Interface extends React.Component {
225244
<>
226245
{isBrowserSupported() ? <Clippy isFixed messageSet="player" /> : <BrowserModal isRtl={isRtl} />}
227246

228-
{(description.instructions === 'unshared' || description.credits === 'unshared') && (
229-
<div className={classNames(styles.infobox, styles.unsharedUpdate)}>
230-
<p><FormattedMessage defaultMessage="Unshared projects are no longer visible." id="tw.unshared2.1" /></p>
231-
<p>
232-
<FormattedMessage
233-
defaultMessage="For more information, visit: {link}"
234-
id="tw.unshared.2"
235-
values={{
236-
link: <a href="https://docs.turbowarp.org/unshared-projects" target="_blank" rel="noopener noreferrer">https://docs.turbowarp.org/unshared-projects</a>
237-
}}
238-
/>
239-
</p>
240-
<p><FormattedMessage defaultMessage="If the project was shared recently, this message may appear incorrectly for a few minutes." id="tw.unshared.cache" /></p>
241-
<p><FormattedMessage defaultMessage="If this project is actually shared, please report a bug." id="tw.unshared.bug" /></p>
242-
</div>
243-
)}
244-
245-
{hasCloudVariables && projectId !== '0' && (
246-
<div className={styles.section}><CloudVariableBadge /></div>
247-
)}
248-
249-
{(description.instructions || description.credits) && (
250-
<div className={styles.section}>
247+
{hasProjectUrl ? (
248+
<>
251249
<Description
252250
instructions={description.instructions}
253251
credits={description.credits}
254252
projectId={projectId}
255253
/>
256-
</div>
254+
</>
255+
) : (
256+
descriptionMessage
257257
)}
258258

259-
<div className={styles.section}>
260-
<p>
261-
<FormattedMessage
262-
defaultMessage="{APP_NAME} is a more powerful Scratch modification that lets you create complex projects easily. Try it out by clicking See Inside!"
263-
id="tw.home.ampdescription"
264-
values={{ APP_NAME }}
265-
/>
266-
</p>
267-
</div>
259+
{hasCloudVariables && projectId !== '0' && (
260+
<div className={styles.section}><CloudVariableBadge /></div>
261+
)}
268262
</>
269263
)}
270264
</div>

0 commit comments

Comments
 (0)