Skip to content

Conversation

@ArgoZhang
Copy link
Member

@ArgoZhang ArgoZhang commented May 16, 2025

Link issues

fixes #6034

Summary By Copilot

Regression?

  • Yes
  • No

Risk

  • High
  • Medium
  • Low

Verification

  • Manual (required)
  • Automated

Packaging changes reviewed?

  • Yes
  • No
  • N/A

☑️ Self Check before Merge

⚠️ Please check all items below before review. ⚠️

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • Merge the latest code from the main branch

Summary by Sourcery

Enable asynchronous message updates by reusing the same MessageOption instance, enhance the Toast JavaScript to maintain a persistent progress element and handle update events consistently, prevent duplicate messages, and add a new async message demo.

New Features:

  • Support asynchronous message content updates using a single MessageOption instance across multiple Show calls
  • Add a demo block for multi-step asynchronous messages

Bug Fixes:

  • Prevent duplicate messages by verifying if a MessageOption is already displayed before adding

Enhancements:

  • Refactor Toast script to retain a progress element reference, unify event handlers, and hide the toast on transition end
  • Enhance update() in the Toast script to correctly toggle auto-hide and clean up progress styles when autohide is disabled

@bb-auto bb-auto bot added the enhancement New feature or request label May 16, 2025
@bb-auto bb-auto bot added this to the v9.6.0 milestone May 16, 2025
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented May 16, 2025

Reviewer's Guide

This PR refactors the toast progress logic to centralize element handling, adds transition‐based hide behavior, and cleans up event listeners, while extending the message component to support asynchronous content updates using a single MessageOption and preventing duplicate messages.

File-Level Changes

Change Details Files
Refactor toast progress and lifecycle handling
  • Capture and store progressElement on init
  • Use transitionend event to auto-hide toast
  • Unify show/hidden handlers to use invoke.invokeMethodAsync
  • Consolidate update logic to adjust or clear progress styles based on autohide
  • Remove all toast and progressElement event listeners in dispose
src/BootstrapBlazor/Components/Toast/Toast.razor.js
Add async message demo with reusable option
  • Introduce a single MessageOption field for reuse
  • Implement ShowAsyncMessage with sequential Task.Delay and Show calls
  • Update Content, Delay, IsAutoHide, and Color between calls
  • Add a DemoBlock for the async example in the razor sample
src/BootstrapBlazor.Server/Components/Samples/Messages.razor.cs
src/BootstrapBlazor.Server/Components/Samples/Messages.razor
Prevent duplicate messages in Message component
  • Check for existing option before adding to _messages
  • Only update _msgId when a new option is added
src/BootstrapBlazor/Components/Message/Message.razor.cs

Assessment against linked issues

Issue Objective Addressed Explanation
#6034 Allow updating the content of a message that has not been closed.
#6034 Allow manually closing a message through code.

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@codecov
Copy link

codecov bot commented May 16, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (ab6c3c1) to head (8aa136f).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #6040   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          701       701           
  Lines        30955     30958    +3     
  Branches      4377      4378    +1     
=========================================
+ Hits         30955     30958    +3     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ArgoZhang ArgoZhang merged commit d5cbb73 into main May 16, 2025
6 checks passed
@ArgoZhang ArgoZhang deleted the refactor-message branch May 16, 2025 14:13
@ArgoZhang ArgoZhang linked an issue May 17, 2025 that may be closed by this pull request
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor(Toast): perfect AutoHide logic feat(MessageService): Manually control when to close message and update message content

2 participants