feat(profile): let users design their public profile

This commit is contained in:
lobo committed 2026-09-28 14:20:14 +02:00
1 parent a5458b3f86
commit b55fcfec92
20 files changed
+674 -138

No files matched your search

+5 -2
View File
@@ -1,9 +1,11 @@
import {useEffect, useState} from 'react';
import {apiFetch} from '../utils/api.js';
import {sessionStamp} from '../utils/auth.js';
import {normalizeProfileStyle} from '../utils/profileStyle.js';
/**
* The stored role and the active role ("view as") of the logged-in user, or null while loading and on any error.
* The stored role, the active role ("view as") and the public profile style of the logged-in user, or null while
* loading and on any error.
* Loads again after a new login or a role switch (see sessionStamp) on the next render.
*/
export default function useCurrentUser(enabled) {
@@ -20,7 +22,8 @@ export default function useCurrentUser(enabled) {
try {
const response = await apiFetch(`${import.meta.env.VITE_API_URL}/api/users/me?v=1`);
const data = response.ok ? await response.json() : null;
if (!cancelled) setUser(data && {role: data.role, activeRole: data.activeRole ?? data.role});
if (!cancelled) setUser(data && {role: data.role, activeRole: data.activeRole ?? data.role,
profileStyle: normalizeProfileStyle(data.settings?.profileStyle)});
} catch {
if (!cancelled) setUser(null);
}