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(uploader): images should display when they've been successfully uploaded #2448

Merged
merged 7 commits into from
Jul 23, 2024

Conversation

Alex-huxiyang
Copy link
Collaborator

@Alex-huxiyang Alex-huxiyang commented Jul 16, 2024

经排查,应该是由状态的不正确更新导致的

  • 日常 bug 修复

Summary by CodeRabbit

  • 新功能

    • 优化了文件上传功能,使用可变引用和可选链语法提升文件列表更新和事件处理的效率。
  • 修复漏洞

    • 修复了在文件上传过程中可能导致的文件列表更新不及时的问题。
  • 重构

    • 重构了上传队列管理、文件处理和事件处理的逻辑,提升代码可读性和维护性。

Copy link

coderabbitai bot commented Jul 16, 2024

Walkthrough

此次更改主要集中在 InternalUploader 组件的逻辑优化,包括文件列表的管理与更新、上传进度的处理、成功响应的处理以及文件超大检查等方面。通过引入 fileListRef 和可选链操作符,代码的可读性和健壮性得到了提升,使得文件上传过程中的状态更新更加准确和清晰。

Changes

文件路径 变化摘要
.../uploader/uploader.taro.tsx, .../uploader/uploader.tsx 引入 fileListRef 作为文件列表的可变引用,使用 fileListRef.current 替代直接引用 fileList,确保在异步操作中访问最新的文件列表。同时,采用可选链 (?.) 调用 onStartonProgressonOversize 函数,重构了上传逻辑,简化了代码结构,提高了可维护性。

Poem

上传新代码,
文件列表展,
可选链如雨,
简洁心头暖。
兔子舞翩跹,
代码世界宽。
🌟🐇🌟


Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 2620d3f and ace0192.

Files selected for processing (2)
  • src/packages/uploader/uploader.taro.tsx (7 hunks)
  • src/packages/uploader/uploader.tsx (10 hunks)
Files skipped from review as they are similar to previous changes (2)
  • src/packages/uploader/uploader.taro.tsx
  • src/packages/uploader/uploader.tsx

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

codecov bot commented Jul 16, 2024

Codecov Report

Attention: Patch coverage is 0% with 6 lines in your changes missing coverage. Please review.

Project coverage is 86.03%. Comparing base (7b0b388) to head (a584452).

Files Patch % Lines
src/packages/uploader/uploader.tsx 0.00% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             next    #2448      +/-   ##
==========================================
+ Coverage   86.01%   86.03%   +0.01%     
==========================================
  Files         217      217              
  Lines       22863    22857       -6     
  Branches     2546     2545       -1     
==========================================
- Hits        19665    19664       -1     
+ Misses       3193     3188       -5     
  Partials        5        5              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Alex-huxiyang Alex-huxiyang changed the title fix(uploader): 修复success后没图片 fix(uploader): images should display when they've been successfully uploaded Jul 16, 2024
@Alex-huxiyang Alex-huxiyang linked an issue Jul 16, 2024 that may be closed by this pull request
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 12

@@ -202,27 +201,27 @@
uploadOption.onStart = (option: UploadOptions) => {
clearUploadQueue(index)
setFileList(
fileList.map((item) => {
[...fileList, fileItem].map((item) => {
Copy link

Choose a reason for hiding this comment

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

请添加测试以覆盖新代码。

根据静态分析工具的警告,这一行新增的代码没有被测试覆盖。

Tools
GitHub Check: codecov/patch

[warning] 204-204: src/packages/uploader/uploader.tsx#L204
Added line #L204 was not covered by tests

src/packages/uploader/uploader.tsx Show resolved Hide resolved
src/packages/uploader/uploader.tsx Outdated Show resolved Hide resolved
src/packages/uploader/uploader.tsx Show resolved Hide resolved
src/packages/uploader/uploader.tsx Outdated Show resolved Hide resolved
src/packages/uploader/uploader.taro.tsx Show resolved Hide resolved
src/packages/uploader/uploader.taro.tsx Outdated Show resolved Hide resolved
src/packages/uploader/uploader.taro.tsx Show resolved Hide resolved
src/packages/uploader/uploader.taro.tsx Outdated Show resolved Hide resolved
src/packages/uploader/uploader.taro.tsx Show resolved Hide resolved
@@ -367,8 +363,6 @@ const InternalUploader: ForwardRefRenderFunction<
readFile(_files)
}

setFileList(fileList)
Copy link
Collaborator

Choose a reason for hiding this comment

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

关注一下数据源的处理位置是否有异常。

@Alex-huxiyang
Copy link
Collaborator Author

思路2: 通过ref存储最新的状态值

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Uploader]组件上传图片不回显
2 participants