Skip to content

doc(Vote): prevent vote under debug env#7315

Merged
ArgoZhang merged 1 commit intomainfrom
feat-pdf
Dec 12, 2025
Merged

doc(Vote): prevent vote under debug env#7315
ArgoZhang merged 1 commit intomainfrom
feat-pdf

Conversation

@ArgoZhang
Copy link
Copy Markdown
Member

@ArgoZhang ArgoZhang commented Dec 12, 2025

Link issues

fixes #7314

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

Bug Fixes:

  • Prevent the vote toast from automatically displaying when the site is running in development/debug mode.

Copilot AI review requested due to automatic review settings December 12, 2025 13:26
@bb-auto bb-auto Bot added the documentation Improvements or additions to documentation label Dec 12, 2025
@bb-auto bb-auto Bot added this to the v10.1.0 milestone Dec 12, 2025
@ArgoZhang ArgoZhang merged commit b39563f into main Dec 12, 2025
4 of 5 checks passed
@ArgoZhang ArgoZhang deleted the feat-pdf branch December 12, 2025 13:26
@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai Bot commented Dec 12, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This PR updates the BaseLayout voting toast behavior so that the vote prompt timeout is skipped when running in a development/debug environment, while preserving existing behavior in non-debug builds, and wires the new JS parameter through from the .NET layout component.

Sequence diagram for BaseLayout vote toast behavior with debug flag

sequenceDiagram
    actor Browser
    participant BlazorBaseLayout
    participant JSRuntime
    participant JSModule

    Browser->>BlazorBaseLayout: Initial render
    activate BlazorBaseLayout
    BlazorBaseLayout->>JSRuntime: LoadModule(Layout/BaseLayout.razor.js)
    JSRuntime-->>BlazorBaseLayout: JSModule
    BlazorBaseLayout->>JSModule: doTask(_interop, IsDevelopment)
    deactivate BlazorBaseLayout

    activate JSModule
    JSModule->>JSModule: initTheme()
    JSModule->>JSModule: read localStorage bb-gitee-vote
    alt bb-gitee-vote is false
        JSModule->>JSModule: remove bb-gitee-vote
    end

    alt IsDevelopment is false
        JSModule->>JSModule: setTimeout(ShowVoteToast, 10000)
        JSModule-->>BlazorBaseLayout: invokeMethodAsync ShowVoteToast
    else IsDevelopment is true
        JSModule->>JSModule: skip vote toast timeout
    end

    Browser->>JSModule: click #bb-gitee-vote
    JSModule->>BlazorBaseLayout: invokeMethodAsync ShowVoteWithGoto
    JSModule->>Browser: hide toast
    Browser->>BlazorBaseLayout: navigate to vote link
    deactivate JSModule
Loading

Flow diagram for updated doTask vote toast logic

flowchart TD
    A_start([start doTask]) --> B_initTheme[initTheme]
    B_initTheme --> C_getVote[Get bb-gitee-vote from localStorage]
    C_getVote --> D_checkVote{bb-gitee-vote exists?}
    D_checkVote -- yes --> E_parseVote[Parse as boolean]
    E_parseVote --> F_checkFalse{value is false?}
    F_checkFalse -- yes --> G_removeVote[Remove bb-gitee-vote]
    F_checkFalse -- no --> H_skipRemove[Keep bb-gitee-vote]
    D_checkVote -- no --> H_skipRemove

    G_removeVote --> I_checkDebug{debug !== true?}
    H_skipRemove --> I_checkDebug

    I_checkDebug -- yes --> J_setTimeout[setTimeout 10s]
    J_setTimeout --> K_invokeToast[invokeMethodAsync ShowVoteToast]
    I_checkDebug -- no --> L_skipTimeout[Skip vote toast timeout]

    K_invokeToast --> M_attachClick[Attach click handler for #bb-gitee-vote]
    L_skipTimeout --> M_attachClick

    M_attachClick --> N_onClick[On click: invoke ShowVoteWithGoto,
close toast, navigate]
    N_onClick --> O_end([end])
Loading

File-Level Changes

Change Details Files
Gate the delayed vote toast display behind a debug flag in the layout JavaScript.
  • Extend the doTask JavaScript function to accept a second debug parameter.
  • Skip scheduling the 10-second ShowVoteToast timeout when debug is true.
  • Keep existing localStorage handling for bb-gitee-vote and related click handlers unchanged.
src/BootstrapBlazor.Server/Components/Layout/BaseLayout.razor.js
Pass the environment flag from the .NET layout component into the JavaScript module.
  • Update the JS interop call to doTask to pass WebsiteOption.Value.IsDevelopment as the debug argument.
  • Ensure the JS module is still loaded from the configured JSModuleRootPath before invoking doTask.
src/BootstrapBlazor.Server/Components/Layout/BaseLayout.razor.cs

Assessment against linked issues

Issue Objective Addressed Explanation
#7314 Change the Vote-related behavior so that the vote toast is not shown when running in a debug/development environment.
#7314 Update documentation to add sample code for the Vote component (or the component referenced by the issue). The PR only modifies BaseLayout.razor.js and BaseLayout.razor.cs to gate the vote toast on the debug flag; it does not include any documentation or sample code changes.

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

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes - here's some feedback:

  • The new debug parameter name in doTask doesn’t clearly match the IsDevelopment value being passed from C#; consider renaming it to something like isDevelopment (and updating the conditional accordingly) to make its intent clearer to future readers.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The new `debug` parameter name in `doTask` doesn’t clearly match the `IsDevelopment` value being passed from C#; consider renaming it to something like `isDevelopment` (and updating the conditional accordingly) to make its intent clearer to future readers.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR prevents the vote notification toast from appearing when the application runs in a development/debug environment, addressing issue #7314.

Key changes:

  • Added a development environment check parameter to the JavaScript doTask function
  • Conditionally skip showing the vote toast when in development mode

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/BootstrapBlazor.Server/Components/Layout/BaseLayout.razor.js Added debug parameter to doTask function and wrapped the vote toast timer in a conditional check to skip execution in development mode
src/BootstrapBlazor.Server/Components/Layout/BaseLayout.razor.cs Passed WebsiteOption.Value.IsDevelopment as a second parameter to the doTask JavaScript function

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

}

export function doTask(invoke) {
export function doTask(invoke, debug) {
Copy link

Copilot AI Dec 12, 2025

Choose a reason for hiding this comment

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

The parameter name "debug" is inconsistent with the C# property name "IsDevelopment" being passed from BaseLayout.razor.cs. Consider renaming the parameter to "isDevelopment" to better reflect what it represents and maintain naming consistency across the codebase.

Copilot uses AI. Check for mistakes.
await invoke.invokeMethodAsync("ShowVoteToast");
}, 10000);

if (debug !== true) {
Copy link

Copilot AI Dec 12, 2025

Choose a reason for hiding this comment

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

The parameter name "debug" is inconsistent with the C# property name "IsDevelopment" being passed from BaseLayout.razor.cs. Consider renaming to "isDevelopment" to better reflect what it represents and maintain naming consistency across the codebase.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

doc(Vote): prevent vote in debug mode

2 participants