Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error when accessing status of empty newChats array #2610

Conversation

fankaiLiu
Copy link

中文模板 / Chinese Template

What kind of change does this PR introduce? (check at least one)

  • Bugfix
  • Feature
  • Code style update
  • Refactor
  • Test Case
  • TypeScript definition update
  • Document improve
  • CI/CD improve
  • Branch sync
  • Other, please describe:

PR description

This PR fixes a bug where an error occurs when accessing the status property of the last chat in newChats array when the array is empty. The fix adds a check to ensure newChats array is not empty before accessing the status property.

Changelog

🇨🇳 Chinese

  • Fix: 修复当 newChats 数组为空时,访问最后一个聊天的 status 属性时出现错误的问题

🇺🇸 English

  • Fix the error that occurs when accessing the status property of the last chat in newChats array when the array is empty

Checklist

  • Test or no need
  • Document or no need
  • Changelog or no need

Other

  • Skip Changelog

Additional information

Copy link

codesandbox-ci bot commented Dec 3, 2024

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit bc6ffd3:

Sandbox Source
pr-story Configuration

@pointhalo pointhalo requested a review from YyumeiZhang December 6, 2024 03:01
if (oldChats.length === 0 || newLastChat.id !== oldLastChat.id) {
shouldScroll = true;
}
} else if (newChats.length === oldChats.length && newChats.length > 0) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

我理解改动的区别如下
image
我理解两者的效果是一致的?
或者可以提供一个复现的 demo 展示下修改前后的区别吗?

Copy link
Author

Choose a reason for hiding this comment

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

Sorry I'm using version 2.68.4, it looks like this issue has been fixed in the new version, it was an oversight on my part not to notice, I'll switch off this pr

@fankaiLiu fankaiLiu closed this Dec 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants