perf: Optimization user input auto close when send message#2790
perf: Optimization user input auto close when send message#2790wangdan-fit2cloud merged 1 commit intomainfrom
Conversation
|
Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
| localStorage.setItem(`${accessToken}userForm`, JSON.stringify(newData)) | ||
| } | ||
| if (!loading.value && props.applicationDetails?.name) { | ||
| handleDebounceClick(val, other_params_data, chat) |
There was a problem hiding this comment.
The provided code is mostly functional but contains an unnecessary else block that can be removed without altering the logic. Additionally, there are style improvements to follow current JavaScript/TypeScript best practices.
Here's the revised version:
function sendMessage(val: string, other_params_data?: any, chat?: chatType): void {
if (!userFormRef.value?.checkInputParam() && isUserInput.value) {
showUserInput.value = true;
return;
}
const userFormData = JSON.parse(localStorage.getItem(`${accessToken}userForm`) || "{}");
Object.keys(form_data.value).forEach(key => {
form_data.value[key] =
Object.prototype.hasOwnProperty.call(userFormData, key)
? userFormData[key]
: form_data.value[key];
});
localStorage.setItem(`${accessToken}userForm`, JSON.stringify(form_data.value));
if (!loading.value && props.applicationDetails?.name) {
handleDebounceClick(val, other_params_data, chat);
}
}Key Changes:
- Reduced Code: Removed the redundant
elseblock, making the code cleaner. - Consistent Type Annotations: Ensured all TypeScript types (
voidinstead of no type annotation where appropriate). - Arrow Functions: Used arrow functions for concise callbacks where applicable.
This should improve readability and maintainability while ensuring correctness.
What this PR does / why we need it?
Summary of your change
Please indicate you've done the following: