-
-
Notifications
You must be signed in to change notification settings - Fork 254
Enhance bit Boilerplate Bswup update (#11159) #11160
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
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughThe update removes the static Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant App (Browser)
participant bswup.ts
participant BitBswup
participant BitBswupProgress
Note over App (Browser): On page load and periodically (every minute)
App (Browser)->>bswup.ts: Invoke tryUpdatingPwa(autoReload)
bswup.ts->>BitBswup: skipWaiting()
alt skipWaiting returns falsy
bswup.ts->>BitBswupProgress: configure({ autoReload })
bswup.ts->>BitBswup: checkForUpdate()
end
Note over bswup.ts: On beforeunload, always autoReload
Note over bswup.ts: Tracks app visibility to control reloads
Estimated code review effort2 (~15 minutes) Poem
✨ Finishing Touches🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. 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 using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this 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 enhances the bit Boilerplate Bswup (Blazor Service Worker Update Progressive) functionality by refactoring the update mechanism and improving automatic update capabilities. The changes consolidate update logic into a dedicated TypeScript module while maintaining backward compatibility.
Key changes:
- Consolidated PWA update logic into a dedicated
bswup.tsmodule with enhanced automatic update strategies - Updated C# service to use the new function name for consistency
- Removed duplicate update functionality from the main app module
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| WebAppUpdateService.cs | Updated JavaScript function call to match new naming convention |
| bswup.ts | New dedicated module implementing comprehensive PWA update logic with background detection and automatic updates |
| app.ts | Removed duplicate forceUpdate method that's now handled by the dedicated bswup module |
src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Scripts/app.ts
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (2)
src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Scripts/bswup.ts (2)
16-18:beforeunloadhandler’s async work is likely discarded.Browsers ignore unresolved promises during
beforeunload; the update check may never complete.
Consider switching to a synchronous hint (e.g.,sendBeacon) or rely solely on the periodic background timer.
32-33: Hard-coded 1-minute polling interval—make configurable.Frequent network polling can drain mobile batteries. Expose the interval via a constant or configuration so teams can tune it without touching source.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Knowledge Base: Disabled due to Reviews > Disable Knowledge Base setting
📒 Files selected for processing (3)
src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Scripts/app.ts(0 hunks)src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Scripts/bswup.ts(1 hunks)src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Web/Services/WebAppUpdateService.cs(1 hunks)
💤 Files with no reviewable changes (1)
- src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Scripts/app.ts
🔇 Additional comments (1)
src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Web/Services/WebAppUpdateService.cs (1)
8-11: Confirm JS interop binding exists (case-sensitive).The C# side now looks for a global JS function named
tryUpdatingPwa.
Ifbswup.tsis compiled as an ES module (default for TypeScript files that useimport/exportsyntax or have"module": "esnext"intsconfig), the function will be scoped to the module and won’t be attached towindow, causing aJSDisconnectedExceptionat runtime.Please verify that the build pipeline outputs
bswup.jsas a classic script (or explicitly attach the function):async function tryUpdatingPwa(autoReload?: boolean) { … } +// Make the function visible to Blazor-JS interop +(window as any).tryUpdatingPwa = tryUpdatingPwa;
closes #11159
Summary by CodeRabbit
New Features
Refactor