Browse Source

Fix exception with appearance reset. Closes #2459

pull/2461/head
Gabe Kangas 3 years ago
parent
commit
f0953a957a
No known key found for this signature in database
GPG Key ID: 4345B2060657F330
  1. 8
      web/pages/admin/config/appearance/index.tsx

8
web/pages/admin/config/appearance/index.tsx

@ -107,7 +107,7 @@ export default function Appearance() {
clearTimeout(resetTimer); clearTimeout(resetTimer);
}; };
useEffect(() => { const setColorDefaults = () => {
const c = {}; const c = {};
[...paletteVariables, ...componentColorVariables, ...chatColorVariables].forEach(color => { [...paletteVariables, ...componentColorVariables, ...chatColorVariables].forEach(color => {
const resolvedColor = getComputedStyle(document.documentElement).getPropertyValue( const resolvedColor = getComputedStyle(document.documentElement).getPropertyValue(
@ -116,6 +116,10 @@ export default function Appearance() {
c[color.name] = { value: resolvedColor.trim(), description: color.description }; c[color.name] = { value: resolvedColor.trim(), description: color.description };
}); });
setColors(c); setColors(c);
};
useEffect(() => {
setColorDefaults();
}, []); }, []);
useEffect(() => { useEffect(() => {
@ -136,13 +140,13 @@ export default function Appearance() {
}; };
const reset = async () => { const reset = async () => {
setColors({});
await postConfigUpdateToAPI({ await postConfigUpdateToAPI({
apiPath: ENDPOINT, apiPath: ENDPOINT,
data: { value: {} }, data: { value: {} },
onSuccess: () => { onSuccess: () => {
setSubmitStatus(createInputStatus(STATUS_SUCCESS, 'Updated.')); setSubmitStatus(createInputStatus(STATUS_SUCCESS, 'Updated.'));
resetTimer = setTimeout(resetStates, RESET_TIMEOUT); resetTimer = setTimeout(resetStates, RESET_TIMEOUT);
setColorDefaults();
}, },
onError: (message: string) => { onError: (message: string) => {
setSubmitStatus(createInputStatus(STATUS_ERROR, message)); setSubmitStatus(createInputStatus(STATUS_ERROR, message));

Loading…
Cancel
Save