v3: allow users to edit dump thumbnail, fixed some linter errors in the frontend
All checks were successful
Build and Publish Docker Image / build-and-push (push) Successful in 41s

This commit is contained in:
khannurien
2026-06-21 15:41:40 +00:00
parent 57cf55cc48
commit cf988ae608
27 changed files with 431 additions and 121 deletions

View File

@@ -263,6 +263,9 @@ export function UserPublicProfile() {
useEffect(() => {
if (!lastUserEvent) return;
const { user } = lastUserEvent;
// Subscribing to the WS-pushed user-update stream — setState here
// mirrors external state into local state, no synchronous alternative.
// eslint-disable-next-line react-hooks/set-state-in-effect
setState((s) => {
if (s.status !== "loaded" || s.user.id !== user.id) return s;
return { ...s, user };
@@ -298,12 +301,17 @@ export function UserPublicProfile() {
if (prevUsername !== username) {
setPrevUsername(username);
setState({ status: "loading" });
prevMyVotesRef.current = null;
setTab("dumps");
setFollowedState(null);
setInviteTreeState(null);
}
// Refs can't be written during render — reset in an effect instead, which
// still runs (and clears the ref) before the vote-diffing effect below.
useEffect(() => {
prevMyVotesRef.current = null;
}, [username]);
useEffect(() => {
if (!username) return;
const controller = new AbortController();
@@ -528,7 +536,7 @@ export function UserPublicProfile() {
) {
return;
}
setFollowedState({ status: "loading" });
queueMicrotask(() => setFollowedState({ status: "loading" }));
const controller = new AbortController();
Promise.all([
fetch(
@@ -578,7 +586,7 @@ export function UserPublicProfile() {
) {
return;
}
setInviteTreeState({ status: "loading" });
queueMicrotask(() => setInviteTreeState({ status: "loading" }));
const controller = new AbortController();
fetch(
`${API_URL}/api/users/${username}/invitees`,
@@ -1396,7 +1404,6 @@ function UpvotedDumpList(
if (!profileUserId || !isOwnProfile) return;
if (prevMyVotesRef.current === null) {
// setVotedIds + prevMyVotesRef must be co-located to stay consistent.
// eslint-disable-next-line react-hooks/set-state-in-effect
setVotedIds(new Set(wsMyVotes));
prevMyVotesRef.current = new Set(wsMyVotes);
return;