Skip to content

Comments

perf: Optimization user input auto close when send message#2790

Merged
wangdan-fit2cloud merged 1 commit intomainfrom
pr@main/perf-user-input
Apr 3, 2025
Merged

perf: Optimization user input auto close when send message#2790
wangdan-fit2cloud merged 1 commit intomainfrom
pr@main/perf-user-input

Conversation

@wangdan-fit2cloud
Copy link
Contributor

What this PR does / why we need it?

Summary of your change

Please indicate you've done the following:

  • Made sure tests are passing and test coverage is added if needed.
  • Made sure commit message follow the rule of Conventional Commits specification.
  • Considered the docs impact and opened a new docs issue or PR with docs changes if needed.

@f2c-ci-robot
Copy link

f2c-ci-robot bot commented Apr 3, 2025

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.

Details

Instructions 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.

@f2c-ci-robot
Copy link

f2c-ci-robot bot commented Apr 3, 2025

[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.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@wangdan-fit2cloud wangdan-fit2cloud merged commit 86e11ba into main Apr 3, 2025
4 checks passed
@wangdan-fit2cloud wangdan-fit2cloud deleted the pr@main/perf-user-input branch April 3, 2025 02:34
localStorage.setItem(`${accessToken}userForm`, JSON.stringify(newData))
}
if (!loading.value && props.applicationDetails?.name) {
handleDebounceClick(val, other_params_data, chat)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

  1. Reduced Code: Removed the redundant else block, making the code cleaner.
  2. Consistent Type Annotations: Ensured all TypeScript types (void instead of no type annotation where appropriate).
  3. Arrow Functions: Used arrow functions for concise callbacks where applicable.

This should improve readability and maintainability while ensuring correctness.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants