Skip to content

refactor(BREAKING): Require client to be initialized for getEventByPushNotification()#2357

Open
krille-chan wants to merge 1 commit into
mainfrom
krille/get-event-by-push-initialized
Open

refactor(BREAKING): Require client to be initialized for getEventByPushNotification()#2357
krille-chan wants to merge 1 commit into
mainfrom
krille/get-event-by-push-initialized

Conversation

@krille-chan

Copy link
Copy Markdown
Contributor

Before we have (in theory) supported that the client does not need to be initialized to call client.getEventByPushNotification() with the intention to allow multiple isolates. However this has never been used (or tested) in any of our clients (thanks to fcm_shared_isolate) and probably never worked. Also suggesting to not need to initialize might more harm than actually been useful. Initializing a client is now possible without waiting for all rooms or other data to be loaded so can be done in very short time.

The current implementation also had the problem that it only loads the token, not the refresh token or refresh token expires in datetime. Instead of duplicating all these logic or abstracting it, I'd find it more clean to remove this "feature" and require to initialize the client before, avoiding confusion, for the sake of simplicity and more intuitive behavior of the SDK.

…shNotification()

Before we have (in theory)
supported that the client
does not need to be initialized
to call client.getEventByPushNotification() with the intention
to allow multiple
isolates. However this has
never been used (or tested) in any of our clients (thanks to fcm_shared_isolate) and
probably never worked.
Also suggesting to not need
to initialize might more
harm than actually been
useful. Initializing a client is
now possible without waiting
for all rooms or other data
to be loaded so can be
done in very short time.

The current implementation
also had the problem that
it only loads the token,
not the refresh token or
refresh token expires in datetime.
Instead of duplicating all these
logic or abstracting it,
I'd find it more clean to
remove this "feature" and
require to initialize
the client before, avoiding
confusion, for the sake of
simplicity and more
intuitive behavior of the
SDK.
@coderabbitai

coderabbitai Bot commented Jun 1, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The PR tightens the contract for Client.getEventByPushNotification by requiring explicit logged-in state. Documentation is updated to reflect this requirement, and a guard clause is added that throws an exception when the client is not logged in, replacing the previous behavior of lazily retrieving an access token from the local database.

Changes

Push Notification Event Fetching

Layer / File(s) Summary
Login requirement enforcement for push notification events
lib/src/client.dart
Documentation updated to require the client be initialized and logged in; guard clause added to throw when isLogged() is false, removing the prior fallback logic that retrieved access tokens from the local database.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main breaking change: requiring client initialization for getEventByPushNotification(), which aligns with the code changes and PR objectives.
Description check ✅ Passed The description is directly related to the changeset, explaining the rationale for removing uninitialized client support and requiring initialization before calling getEventByPushNotification().
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch krille/get-event-by-push-initialized

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 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 `@lib/src/client.dart`:
- Line 1858: Correct the spelling in the documentation comment that currently
reads "The client **must** be initialized and looged in or will otherwise" by
replacing "looged" with "logged" so it reads "The client **must** be initialized
and logged in or will otherwise"; update the doc comment in lib/src/client.dart
(the comment block containing that sentence) to fix the typo.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 1caddab3-a37b-4a7f-a203-98f03ed402a6

📥 Commits

Reviewing files that changed from the base of the PR and between 8a9a2fa and 0aef5d5.

📒 Files selected for processing (1)
  • lib/src/client.dart

Comment thread lib/src/client.dart
/// initialized, it will only fetch the necessary parts of the database. This
/// should make it possible to run this parallel to another client with the
/// same client name.
/// The client **must** be initialized and looged in or will otherwise

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Fix typo in documentation.

Line 1858 contains a spelling error: "looged" should be "logged".

📝 Proposed fix
-  /// The client **must** be initialized and looged in or will otherwise
+  /// The client **must** be initialized and logged in or will otherwise
📝 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.

Suggested change
/// The client **must** be initialized and looged in or will otherwise
/// The client **must** be initialized and logged in or will otherwise
🤖 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 `@lib/src/client.dart` at line 1858, Correct the spelling in the documentation
comment that currently reads "The client **must** be initialized and looged in
or will otherwise" by replacing "looged" with "logged" so it reads "The client
**must** be initialized and logged in or will otherwise"; update the doc comment
in lib/src/client.dart (the comment block containing that sentence) to fix the
typo.

@codecov

codecov Bot commented Jun 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 59.27%. Comparing base (286cdbe) to head (0aef5d5).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2357      +/-   ##
==========================================
+ Coverage   59.26%   59.27%   +0.01%     
==========================================
  Files         161      161              
  Lines       20060    20057       -3     
==========================================
+ Hits        11888    11889       +1     
+ Misses       8172     8168       -4     
Files with missing lines Coverage Δ
lib/src/client.dart 78.02% <100.00%> (+0.21%) ⬆️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 286cdbe...0aef5d5. Read the comment docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant