From c48c0cecd70c56ab25a390712130b599bd6b2076 Mon Sep 17 00:00:00 2001
From: Mistium <92952823+Mistium@users.noreply.github.com>
Date: Thu, 8 Oct 2026 14:53:32 +0100
Subject: [PATCH 01/16] Keep the project and profile pages on screen after
owner and admin actions
---
src/community/pages/Profile.jsx | 32 ++++++++++++++++++++------------
src/community/pages/Project.jsx | 17 ++++++++++-------
2 files changed, 30 insertions(+), 19 deletions(-)
diff --git a/src/community/pages/Profile.jsx b/src/community/pages/Profile.jsx
index 6998aeb1fe0..85481fa665e 100644
--- a/src/community/pages/Profile.jsx
+++ b/src/community/pages/Profile.jsx
@@ -245,11 +245,13 @@ const Profile = () => {
}, [name, viewerName, load]);
useEffect(() => {
- if (!user || !user.isAdmin) {
- setAdminProjects([]);
- setAdminUser(null);
- return () => {};
- }
+ setAdminProjects([]);
+ setAdminUser(null);
+ setAdminLevel('good');
+ setAdminReason('');
+ setAdminMessage('');
+ setAdminNote(null);
+ if (!user || !user.isAdmin) return () => {};
let active = true;
api.admin.getUser(name)
.then(data => {
@@ -268,26 +270,30 @@ const Profile = () => {
};
}, [name, user]);
- const refreshAdminUser = useCallback(async () => {
+ const refreshAdminUser = useCallback(async context => {
const data = await api.admin.getUser(name);
+ if (actionContextRef.current !== context) return;
setAdminUser(data);
- setMwUser(current => (current ? {...current, banned: data.banned} : current));
+ setMwUser(current => (current ? {...current, banned: data.banned, commentsOff: data.commentsOff} : current));
setAdminLevel((data.standing && data.standing.level) || 'good');
setAdminProjects(data.projects || []);
}, [name]);
const runAdminAction = useCallback(async (key, action, success) => {
if (adminBusy) return;
+ const context = actionContextRef.current;
setAdminBusy(key);
setAdminNote(null);
try {
await action();
- await refreshAdminUser();
- setAdminNote({text: success, error: false});
+ await refreshAdminUser(context);
+ if (actionContextRef.current === context) setAdminNote({text: success, error: false});
} catch (requestError) {
- setAdminNote({text: requestError.message || communityText('Moderation action failed.'), error: true});
+ if (actionContextRef.current === context) {
+ setAdminNote({text: requestError.message || communityText('Moderation action failed.'), error: true});
+ }
} finally {
- setAdminBusy('');
+ if (actionContextRef.current === context) setAdminBusy('');
}
}, [adminBusy, communityText, refreshAdminUser]);
@@ -388,7 +394,9 @@ const Profile = () => {
setActionError(null);
try {
await api.updateProfile({commentsOff: !commentsOff});
- if (actionContextRef.current === context) load();
+ if (actionContextRef.current === context) {
+ setMwUser(current => (current ? {...current, commentsOff: !commentsOff} : current));
+ }
} catch (e) {
if (actionContextRef.current === context) {
setActionError(e.message || 'Could not update comments.');
diff --git a/src/community/pages/Project.jsx b/src/community/pages/Project.jsx
index 5020ae05a19..4bc367e39bf 100644
--- a/src/community/pages/Project.jsx
+++ b/src/community/pages/Project.jsx
@@ -249,7 +249,7 @@ const Project = () => {
useEffect(() => {
if (project) setTitle(project.title || '');
- }, [project]);
+ }, [project?.id, project?.title]);
useEffect(() => {
if (!project) return;
@@ -373,7 +373,7 @@ const Project = () => {
if (actionContextRef.current !== context) return;
setActionError(null);
setProject(data.project);
- setProjectLoadContext(context);
+ setProjectLoadContext(id);
} catch (e) {
if (actionContextRef.current === context) {
setActionError(e.message || 'Could not update visibility.');
@@ -399,7 +399,7 @@ const Project = () => {
const fresh = await buyProject(id);
if (actionContextRef.current !== context) return;
setProject(fresh);
- setProjectLoadContext(context);
+ setProjectLoadContext(id);
setConfirmBuy(false);
} catch (e) {
if (actionContextRef.current !== context) return;
@@ -421,7 +421,7 @@ const Project = () => {
if (actionContextRef.current !== context) return;
setActionError(null);
setProject(data.project);
- setProjectLoadContext(context);
+ setProjectLoadContext(id);
} catch (e) {
if (actionContextRef.current === context) {
setActionError(e.message || 'Could not update comments.');
@@ -450,12 +450,14 @@ const Project = () => {
};
const toggleLibrary = async () => {
+ if (!project) return;
const context = actionContextRef.current;
const actionKey = beginAction('library');
if (!actionKey) return;
setSavingLibrary(true);
try {
let result;
+ const nextSaved = !project.saved;
if (project.saved) {
result = await api.unsaveProject(id);
} else {
@@ -463,11 +465,12 @@ const Project = () => {
}
if (actionContextRef.current !== context) return;
setProject(current => {
- const wasSaved = Boolean(current.saved);
- const fallbackCount = Math.max(0, (Number(current.saveCount) || 0) + (wasSaved ? -1 : 1));
+ if (!current) return current;
+ const count = Number(current.saveCount) || 0;
+ const fallbackCount = Boolean(current.saved) === nextSaved ? count : Math.max(0, count + (nextSaved ? 1 : -1));
return {
...current,
- saved: !wasSaved,
+ saved: nextSaved,
saveCount: Number.isFinite(result.saves) ? result.saves : fallbackCount
};
});
From 355a3ca26546d7441e30b8ca498099a3baeb9fd7 Mon Sep 17 00:00:00 2001
From: Mistium <92952823+Mistium@users.noreply.github.com>
Date: Thu, 8 Oct 2026 14:53:32 +0100
Subject: [PATCH 02/16] Stop comment search retrying forever and show comment
errors where they happened
---
src/community/components/CommentThread.jsx | 24 ++++++++++++++--------
1 file changed, 16 insertions(+), 8 deletions(-)
diff --git a/src/community/components/CommentThread.jsx b/src/community/components/CommentThread.jsx
index 449784c28bc..6c25495e368 100644
--- a/src/community/components/CommentThread.jsx
+++ b/src/community/components/CommentThread.jsx
@@ -342,7 +342,11 @@ const CommentThread = ({
const [replyTo, setReplyTo] = useState(null);
const [replyText, setReplyText] = useState('');
const [busy, setBusy] = useState(false);
- const [error, setError] = useState(null);
+ const [errorState, setErrorState] = useState(null);
+ const setError = useCallback((message, target = 'general') => {
+ setErrorState(message ? {text: message, target} : null);
+ }, []);
+ const errorFor = target => (errorState && errorState.target === target ? errorState.text : null);
const [loadingComments, setLoadingComments] = useState(true);
const [loadFailed, setLoadFailed] = useState(false);
const [reportId, setReportId] = useState(null);
@@ -359,6 +363,7 @@ const CommentThread = ({
const [nextOffset, setNextOffset] = useState(0);
const [loadingMore, setLoadingMore] = useState(false);
const [moreFailed, setMoreFailed] = useState(false);
+ const failedFullLoad = useRef('');
const [allCommentsLoaded, setAllCommentsLoaded] = useState(false);
const sourceRef = useRef(source);
const viewerRef = useRef(viewerName);
@@ -559,6 +564,8 @@ const CommentThread = ({
useEffect(() => {
if (!projectComments || allCommentsLoaded || loadingComments || loadingMore) return;
if (!search.trim() && kindFilter === 'all') return;
+ const loadKey = `${search.trim()}\u0000${kindFilter}\u0000${sortOrder}`;
+ if (failedFullLoad.current === loadKey) return;
const actionSource = source;
const actionViewer = viewerName;
const fresh = beginExtraLoad();
@@ -578,6 +585,7 @@ const CommentThread = ({
setLoadingMore(false);
}))
.catch(fresh(() => {
+ failedFullLoad.current = loadKey;
setMoreFailed(true);
setLoadingMore(false);
}));
@@ -606,7 +614,7 @@ const CommentThread = ({
if (!text.trim()) return;
const attachedDonation = parent ? 0 : parseCommentDonation(donation);
if (attachedDonation === null) {
- setError(communityText('Enter a donation between 0.01 and 100000 credits.'));
+ setError(communityText('Enter a donation between 0.01 and 100000 credits.'), 'root');
return;
}
const actionSource = source;
@@ -648,7 +656,7 @@ const CommentThread = ({
if (sourceRef.current === actionSource && viewerRef.current === actionViewer) {
setError(e.cancelled ?
communityText('Payment cancelled.') :
- (e.message || communityText('Could not post comment.')));
+ (e.message || communityText('Could not post comment.')), parent || 'root');
}
} finally {
releaseAction();
@@ -683,7 +691,7 @@ const CommentThread = ({
setDeleteId(null);
} catch (e) {
if (sourceRef.current === actionSource && viewerRef.current === actionViewer) {
- setError(e.message || communityText('Could not delete comment.'));
+ setError(e.message || communityText('Could not delete comment.'), 'delete');
}
} finally {
releaseAction();
@@ -847,7 +855,7 @@ const CommentThread = ({
placeholder={communityText('Add a comment')}
ariaLabel={communityText('Add a comment')}
busy={busy}
- error={replyTo === null ? error : null}
+ error={errorFor('root') || (replyTo === null ? errorFor('general') : null)}
kind={projectComments ? kind : null}
onKindChange={projectComments ? setKind : null}
composerAction={composerAction}
@@ -1019,7 +1027,7 @@ const CommentThread = ({
placeholder={communityText('Reply to {value1}', {value1: comment.author})}
ariaLabel={communityText('Write a reply')}
busy={busy}
- error={error}
+ error={errorFor(comment.id)}
/>
) : null}
@@ -1069,7 +1077,7 @@ const CommentThread = ({
{communityText('No comments match those filters.')}
) : null}
- {!loadingComments && !loadFailed && !comments.length ? (
+ {!disabled && !loadingComments && !loadFailed && !comments.length ? (
{communityText('Goes back to good standing on {value1}.', {value1: formatDate(standing.recoverAt)})}
@@ -556,12 +611,12 @@ const UserDetailCard = ({username, onBack}) => { />{space.description || communityText('No description yet.')}
{space.owner ? ( - {communityText('by ')} -{communityText('No projects have been added yet.')}
: null}{rich('by {user}', {user: {'sam'}})}
+ ); + expect(markup).toBe('by sam
'); + }); + + test('follows the word order of the translation', () => { + const rich = createRichTranslator(createTranslator('fr', {'by {user}': '{user} l’a créé'})); + const markup = renderToStaticMarkup({rich('by {user}', {user: {'sam'}})}
); + expect(markup).toBe('sam l’a créé
'); + }); + + test('says "just now" without adding "ago"', () => { + expect(timeAgoText(Date.now())).toBe('just now'); + expect(timeAgoText(Date.now() - (5 * 60 * 1000))).toBe('5m ago'); + expect(timeAgoText(0)).toBe(''); + }); +}); From dfc4c4ef624bddc1d30b89236a954a221dc22d3c Mon Sep 17 00:00:00 2001 From: Mistium <92952823+Mistium@users.noreply.github.com> Date: Thu, 8 Oct 2026 15:50:57 +0100 Subject: [PATCH 10/16] Trust the server's challenge phase, keep judges off their own entry and add keyboard rating --- src/community/pages/Challenge.jsx | 85 ++++++++++++++++++++++--------- 1 file changed, 62 insertions(+), 23 deletions(-) diff --git a/src/community/pages/Challenge.jsx b/src/community/pages/Challenge.jsx index 2d04446f894..23ece849475 100644 --- a/src/community/pages/Challenge.jsx +++ b/src/community/pages/Challenge.jsx @@ -1,4 +1,4 @@ -import {getCommunityLocale} from '../locale.js'; +import {formatCommunityMessage, getCommunityLocale} from '../locale.js'; import {useCommunityIntl as useCommunityText} from '../i18n.jsx'; /* eslint-disable max-len */ import React, {useEffect, useRef, useState} from 'react'; @@ -48,7 +48,7 @@ const timestamp = value => { const dateTime = value => { const parsed = timestamp(value); - return parsed ? new Date(parsed).toLocaleString(getCommunityLocale(), {dateStyle: 'medium', timeStyle: 'short'}) : 'Not set'; + return parsed ? new Date(parsed).toLocaleString(getCommunityLocale(), {dateStyle: 'medium', timeStyle: 'short'}) : formatCommunityMessage('Not set'); }; export const challengePhase = (space, now) => { @@ -137,6 +137,20 @@ export const nextUnscoredEntry = (projects, currentId) => { const STAR_VALUES = [1, 2, 3, 4, 5]; +const RADIO_STEPS = {ArrowRight: 1, ArrowUp: 1, ArrowLeft: -1, ArrowDown: -1}; + +const radioKeyTarget = (event, index, count) => { + let next = null; + if (event.key in RADIO_STEPS) next = Math.max(0, Math.min(count - 1, index + RADIO_STEPS[event.key])); + else if (event.key === 'Home') next = 0; + else if (event.key === 'End') next = count - 1; + if (next === null) return null; + event.preventDefault(); + const button = event.currentTarget.parentElement.children[next]; + if (button) button.focus(); + return next; +}; + const StarRating = ({className, average, count, myVote, revealed, interactive, busy, note, title, onRate}) => { const {text: communityText} = useCommunityText(); const [preview, setPreview] = useState(0); @@ -156,12 +170,14 @@ const StarRating = ({className, average, count, myVote, revealed, interactive, b{communityText('Winning entry by')}{' '}
{communityRich('Winning entry by {user}', {user: