-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix state error when is debouncing changes on integers inputs (#1848)
🐛 (index.tsx): fix missing line break after handleUpdateValues function call ✨ (index.tsx): improve performance by debouncing handleUpdateValues function call for certain types of parameters 📝 (parameterUtils.ts): update handleUpdateValues function to use optional chaining for accessing template properties 🚀 (chatInputOutput.spec.ts): remove unused imports and commented code 🚀 (dragAndDrop.spec.ts): fix typo in test description
- Loading branch information
Showing
4 changed files
with
51 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,38 @@ | ||
import { debounce } from "lodash"; | ||
import { SAVE_DEBOUNCE_TIME } from "../constants/constants"; | ||
import { postCustomComponentUpdate } from "../controllers/API"; | ||
import { ResponseErrorTypeAPI } from "../types/api"; | ||
import { NodeDataType } from "../types/flow"; | ||
|
||
export const handleUpdateValues = async (name: string, data: NodeDataType) => { | ||
const code = data.node?.template["code"]?.value; | ||
const code = data.node?.template?.code?.value; | ||
if (!code) { | ||
console.error("Code not found in the template"); | ||
return; | ||
} | ||
|
||
const template = data.node?.template; | ||
if (!template) { | ||
console.error("No template found in the node."); | ||
return; | ||
} | ||
|
||
try { | ||
let newTemplate = await postCustomComponentUpdate( | ||
const res = await postCustomComponentUpdate( | ||
code, | ||
template, | ||
name, | ||
data.node?.template[name]?.value | ||
) | ||
.then((res) => { | ||
console.log("res", res); | ||
if (res.status === 200 && data.node?.template) { | ||
return res.data.template; | ||
} | ||
}) | ||
.catch((error) => { | ||
throw error; | ||
}); | ||
return newTemplate; | ||
data.node?.template[name]?.value, | ||
); | ||
if (res.status === 200 && data.node?.template) { | ||
return res.data.template; | ||
} | ||
} catch (error) { | ||
console.error("Error occurred while updating the node:", error); | ||
let errorType = error as ResponseErrorTypeAPI; | ||
throw errorType; | ||
throw error; | ||
} | ||
}; | ||
|
||
export const debouncedHandleUpdateValues = debounce( | ||
handleUpdateValues, | ||
SAVE_DEBOUNCE_TIME | ||
SAVE_DEBOUNCE_TIME, | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters