Skip to content

Commit d5a4982

Browse files
committed
Merge branch 'develop' into feat/pagination-copy
2 parents e3ab5fb + d78c8af commit d5a4982

File tree

7 files changed

+40
-14
lines changed

7 files changed

+40
-14
lines changed

client/modules/App/components/Overlay.tsx

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useCallback, useRef } from 'react';
2-
import MediaQuery from 'react-responsive';
2+
import { useMediaQuery } from 'react-responsive';
33
import { useSelector } from 'react-redux';
44
import { useHistory } from 'react-router-dom';
55
import { useTranslation } from 'react-i18next';
@@ -9,8 +9,8 @@ import type { RootState } from '../../../reducers';
99
import ExitIcon from '../../../images/exit.svg';
1010

1111
type OverlayProps = {
12-
children?: React.ReactElement;
13-
actions?: React.ReactElement;
12+
children?: React.ReactNode;
13+
actions?: React.ReactNode;
1414
closeOverlay?: () => void;
1515
title?: string;
1616
ariaLabel?: string;
@@ -35,6 +35,9 @@ export const Overlay = ({
3535

3636
const browserHistory = useHistory();
3737

38+
const isDesktop = useMediaQuery({ minWidth: 770 });
39+
const isMobile = useMediaQuery({ maxWidth: 769 });
40+
3841
const close = useCallback(() => {
3942
const node = ref.current;
4043
if (!node) return;
@@ -66,7 +69,7 @@ export const Overlay = ({
6669
<header className="overlay__header">
6770
<h2 className="overlay__title">{title}</h2>
6871
<div className="overlay__actions">
69-
<MediaQuery minWidth={770}>{actions}</MediaQuery>
72+
{isDesktop && actions}
7073
<button
7174
className="overlay__close-button"
7275
onClick={close}
@@ -76,11 +79,9 @@ export const Overlay = ({
7679
</button>
7780
</div>
7881
</header>
79-
<MediaQuery maxWidth={769}>
80-
{actions && (
81-
<div className="overlay__actions-mobile">{actions}</div>
82-
)}
83-
</MediaQuery>
82+
{isMobile && actions && (
83+
<div className="overlay__actions-mobile">{actions}</div>
84+
)}
8485
{children}
8586
</section>
8687
</div>

common/p5Versions.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ export const currentP5Version = '1.11.11'; // Don't update to 2.x until 2026
55
// JSON.stringify([...document.querySelectorAll('._132722c7')].map(n => n.innerText), null, 2)
66
// TODO: use their API for this to grab these at build time?
77
export const p5Versions = [
8-
{ version: '2.1.2', label: '(Beta)' },
8+
{ version: '2.2.0', label: '(Beta)' },
9+
'2.1.2',
910
'2.1.1',
1011
'2.0.5',
1112
'2.0.4',

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "p5.js-web-editor",
3-
"version": "2.19.4",
3+
"version": "2.19.7",
44
"description": "The web editor for p5.js.",
55
"scripts": {
66
"clean": "rimraf dist",

server/controllers/project.controller.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,12 @@ export async function changeProjectVisibility(req, res) {
296296
.json({ success: false, message: 'No project found.' });
297297
}
298298

299+
if (!project.user.equals(req.user._id)) {
300+
return res
301+
.status(403)
302+
.json({ success: false, message: 'Unauthorized action.' });
303+
}
304+
299305
if (newVisibility !== 'Private' && newVisibility !== 'Public') {
300306
return res.status(400).json({ success: false, message: 'Invalid data.' });
301307
}

server/routes/project.routes.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@ router.get('/:username/projects', ProjectController.getProjectsForUser);
2626

2727
router.get('/projects/:project_id/zip', ProjectController.downloadProjectAsZip);
2828

29-
router.patch('/project/visibility', ProjectController.changeProjectVisibility);
29+
router.patch(
30+
'/project/visibility',
31+
isAuthenticated,
32+
ProjectController.changeProjectVisibility
33+
);
3034

3135
// eslint-disable-next-line import/no-default-export
3236
export default router;

server/server.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,20 @@ app.get('*', async (req, res) => {
195195
res.type('txt').send('Not found.');
196196
});
197197

198+
// Global error handler for unhandled errors
199+
app.use((error, req, res, next) => {
200+
console.error('Unhandled error:', error);
201+
202+
if (res.headersSent) {
203+
return next(error);
204+
}
205+
206+
const statusCode = error.status || 500;
207+
return res.status(statusCode).json({
208+
error: 'Internal server error'
209+
});
210+
});
211+
198212
// start app
199213
app.listen(process.env.PORT, (error) => {
200214
if (!error) {

0 commit comments

Comments
 (0)