Repository navigation
feat: New useTimer hook - #25335
feat: New useTimer hook#25335
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughAdds timer data normalization for plugin consumption. Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant PluginDataConsumptionManager
participant TimerHookContainer
participant useTimer
participant formatTimerResponseFromGraphql
participant window
PluginDataConsumptionManager->>TimerHookContainer: render for DataConsumptionHooks.TIMER
TimerHookContainer->>useTimer: read timer data and loading state
TimerHookContainer->>TimerHookContainer: compare version with previous value
alt version increases or timerData changes
TimerHookContainer->>formatTimerResponseFromGraphql: format timer response
formatTimerResponseFromGraphql-->>TimerHookContainer: GraphqlResponseWrapper<TimerData>
TimerHookContainer->>window: dispatchEvent(CustomEvent<TimerData>)
end
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
|
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@bigbluebutton-html5/imports/ui/components/plugins-engine/data-consumption/domain/timer/hook-manager.tsx`:
- Around line 30-39: The timer update logic in hook-manager currently dispatches
the same TIMER payload twice on mount and can also retrigger on unrelated
rerenders because the separate useEffect blocks watch both version and the
unstable timerData object. Refactor the logic around updateTimerForPlugin so
there is a single effect that runs only when version changes and when the actual
timer fields used for the payload change, or memoize the payload before using it
as a dependency, to avoid duplicate dispatches.
In `@bigbluebutton-html5/imports/ui/core/hooks/useTimer.ts`:
- Line 40: The empty-state branch in useTimer is dropping the first query error,
so when no timer row exists the caller cannot see a failed response. Update the
early return in useTimer to preserve response.errors?.[0] alongside the existing
loading state, matching the shape used by the rest of the hook’s return object
so the plugin formatter can surface the failure correctly.
In `@bigbluebutton-html5/package.json`:
- Line 82: The dependency for bigbluebutton-html-plugin-sdk is pinned to a
GitHub tarball commit instead of a published semver release, so confirm whether
this is intentional; if not, update the entry in package.json to a tagged
published version rather than the codeload URL. After changing the resolution,
regenerate and commit the matching package-lock.json so npm ci and CI installs
stay in sync, and verify no stale 0.0.100 references remain in the lockfile or
other manifests.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 6980a2d5-45df-42b2-93fd-bf7f9e15d034
⛔ Files ignored due to path filters (1)
bigbluebutton-html5/package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (5)
bigbluebutton-html5/imports/ui/components/plugins-engine/data-consumption/domain/timer/hook-manager.tsxbigbluebutton-html5/imports/ui/components/plugins-engine/data-consumption/domain/timer/utils.tsbigbluebutton-html5/imports/ui/components/plugins-engine/data-consumption/manager.tsxbigbluebutton-html5/imports/ui/core/hooks/useTimer.tsbigbluebutton-html5/package.json
| useEffect(() => { | ||
| const previousVersionValue = previousVersion ?? 0; | ||
| if (version > previousVersionValue) { | ||
| updateTimerForPlugin(); | ||
| } | ||
| }, [version]); | ||
|
|
||
| useEffect(() => { | ||
| updateTimerForPlugin(); | ||
| }, [timerData]); |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Avoid double-dispatching TIMER updates.
Lines 30-39 can emit the same payload twice on mount: once because previousVersion is initially undefined, and again because the timerData effect always runs after mount. Since useTimer() returns a new object each render, Line 37 can also retrigger on unrelated rerenders.
Collapse this into one effect keyed on version plus stable timer fields, or memoize the payload before using it as a dependency.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In
`@bigbluebutton-html5/imports/ui/components/plugins-engine/data-consumption/domain/timer/hook-manager.tsx`
around lines 30 - 39, The timer update logic in hook-manager currently
dispatches the same TIMER payload twice on mount and can also retrigger on
unrelated rerenders because the separate useEffect blocks watch both version and
the unstable timerData object. Refactor the logic around updateTimerForPlugin so
there is a single effect that runs only when version changes and when the actual
timer fields used for the payload change, or memoize the payload before using it
as a dependency, to avoid duplicate dispatches.
| }, []); | ||
|
|
||
| if (!response.data?.[0]) return { data: undefined }; | ||
| if (!response.data?.[0]) return { data: undefined, loading: response.loading }; |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
Preserve error in the empty-state return.
Line 40 still drops response.errors?.[0]. When the query fails before any timer row exists, the plugin formatter can only emit an empty timer instead of a failed response.
Suggested fix
- if (!response.data?.[0]) return { data: undefined, loading: response.loading };
+ if (!response.data?.[0]) {
+ return {
+ data: undefined,
+ loading: response.loading,
+ error: response.errors?.[0],
+ };
+ }📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| if (!response.data?.[0]) return { data: undefined, loading: response.loading }; | |
| if (!response.data?.[0]) { | |
| return { | |
| data: undefined, | |
| loading: response.loading, | |
| error: response.errors?.[0], | |
| }; | |
| } |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@bigbluebutton-html5/imports/ui/core/hooks/useTimer.ts` at line 40, The
empty-state branch in useTimer is dropping the first query error, so when no
timer row exists the caller cannot see a failed response. Update the early
return in useTimer to preserve response.errors?.[0] alongside the existing
loading state, matching the shape used by the rest of the hook’s return object
so the plugin formatter can surface the failure correctly.
|
This pull request has conflicts ☹ |
✅ Automated tests have passed! |
e61a956
into
bigbluebutton:v3.0.x-develop
3.0's plugin-sdk-use-timer work (#25335, commits bc4e822 / 172d67d / 388960c) adds a TIMER data-consumption hook and pairs it with plugin SDK 0.0.104. It merges cleanly on file level but does not compile on 4.0, because it depends on SDK APIs that exist only on the 0.0.x line: - `TimerData` is not exported (TS2694) - `DataConsumptionHooks.TIMER` does not exist (TS2339) - `useTimer(...)` takes a boolean, not `{ enableNotifications, isIndicator }` (TS2345) 4.0 tracks the 0.1.x SDK line (html5PluginSdkVersion=0.1.24). I checked the published SDK: neither 0.1.24 nor 0.1.25, the latest on that line, declares TIMER in DataConsumptionHooks — the enum ends at CUSTOM_QUERY. So there is no 0.1.x version to bump to that would make this compile, and bumping to 0.0.104 would drag 4.0's plugin API back to the 3.0 line. Removing the client half here rather than leaving 4.0 unbuildable. The feature needs a real port once the 0.1.x SDK exposes the timer types, which is an SDK change, not a merge conflict resolution. Nothing else references the hook: the two files were added whole by the merge and the only other reference was the registration in data-consumption/manager.tsx, removed here too. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>



What does this PR do?
It creates a new hook
useTimerthat mirrors the same hook from the core html5 client functions.Motivation
This will resolve this comment and therefore we'll be able to make the suggestion in the issue as a Plugin.
More
This PR is closely related with the PR in the SDK: bigbluebutton/bigbluebutton-html-plugin-sdk#272