mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-09 10:34:17 +00:00
debouce pushing changes to server
This commit is contained in:
parent
bf58669117
commit
df88991bdf
@ -1,7 +1,12 @@
|
||||
import React from "react"
|
||||
import lodash from "lodash"
|
||||
|
||||
import UserModel from "@models/user"
|
||||
|
||||
const pushToServer = lodash.debounce(async (update) => {
|
||||
return await UserModel.updateConfig(update)
|
||||
}, 500)
|
||||
|
||||
export default (props = {}) => {
|
||||
const [firstLoad, setFirstLoad] = React.useState(true)
|
||||
const [localData, setLocalData] = React.useState({})
|
||||
@ -18,8 +23,8 @@ export default (props = {}) => {
|
||||
props.onUpdate(localData)
|
||||
}
|
||||
|
||||
const config = await UserModel.updateConfig(update)
|
||||
setLocalData(config)
|
||||
setLocalData(update)
|
||||
pushToServer(update)
|
||||
}
|
||||
|
||||
return [
|
||||
|
Loading…
x
Reference in New Issue
Block a user