0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-03-11 02:12:21 -05:00

Added debounce to background colour picker (#18052)

no issue

---

<!-- Leave the line below if you'd like GitHub Copilot to generate a
summary from your commit -->
<!--
copilot:summary
-->
### <samp>🤖 Generated by Copilot at 910bfbe</samp>

Optimized theme settings component to use debounced function for
updating settings. This reduces API requests and improves UX.
This commit is contained in:
Ronald Langeveld 2023-09-11 19:32:35 +07:00 committed by GitHub
parent dd7df1ec6c
commit f7f0f3033e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -8,6 +8,7 @@ import SettingGroupContent from '../../../../admin-x-ds/settings/SettingGroupCon
import TextField from '../../../../admin-x-ds/global/form/TextField';
import Toggle from '../../../../admin-x-ds/global/form/Toggle';
import {CustomThemeSetting} from '../../../../api/customThemeSettings';
import {debounce} from '../../../../utils/debounce';
import {getImageUrl, useUploadImage} from '../../../../api/images';
import {humanizeSettingKey} from '../../../../api/settings';
@ -22,6 +23,8 @@ const ThemeSetting: React.FC<{
setSetting(imageUrl);
};
const updateSettingDebounced = debounce(setSetting, 500);
switch (setting.type) {
case 'text':
return (
@ -59,7 +62,7 @@ const ThemeSetting: React.FC<{
hint={setting.description}
title={humanizeSettingKey(setting.key)}
value={setting.value || ''}
onChange={value => setSetting(value)}
onChange={value => updateSettingDebounced(value)}
/>
);
case 'image':