From c1d4192d6e2edabdc8c208bab52fd9a9adb9ff32 Mon Sep 17 00:00:00 2001 From: SrGooglo Date: Sat, 22 Apr 2023 23:03:25 +0000 Subject: [PATCH] support `onDebounceSave` --- packages/app/src/pages/settings/index.jsx | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/packages/app/src/pages/settings/index.jsx b/packages/app/src/pages/settings/index.jsx index acd2086e..b8df5864 100755 --- a/packages/app/src/pages/settings/index.jsx +++ b/packages/app/src/pages/settings/index.jsx @@ -13,10 +13,10 @@ import getSettingsList from "schemas/settings" import menuGroupsDecorators from "schemas/settingsMenuGroupsDecorators" import groupsDecorators from "schemas/settingsGroupsDecorators" -const SettingsList = await getSettingsList() - import "./index.less" +const SettingsList = await getSettingsList() + const extraMenuItems = [ { id: "donate", @@ -72,6 +72,7 @@ const SettingItem = (props) => { const [value, setValue] = React.useState(null) const [delayedValue, setDelayedValue] = React.useState(null) const [disabled, setDisabled] = React.useState(false) + const componentRef = React.useRef(null) let SettingComponent = item.component @@ -137,6 +138,12 @@ const SettingItem = (props) => { setDelayedValue(null) } + if (componentRef.current) { + if (typeof componentRef.current.onDebounceSave === "function") { + await componentRef.current.onDebounceSave(updateValue) + } + } + setValue(updateValue) } @@ -344,7 +351,8 @@ const SettingItem = (props) => { ?
Loading...
: React.createElement(SettingComponent, { ...item.props, - ctx: elementsCtx + ctx: elementsCtx, + ref: componentRef, })}