Skip to content

Conversation

@xsahil03x
Copy link
Member

@xsahil03x xsahil03x commented Dec 4, 2025

Submit a pull request

Fixes: FLU-340
Docs: https://github.com/GetStream/docs-content/pull/836

Description of the pull request

Adds the hideHistoryBefore parameter to the addMembers and addChannelMembers methods.

This allows specifying a timestamp before which channel history should be hidden for newly added members. When hideHistoryBefore is provided, it takes precedence over the existing hideHistory boolean flag.

Summary by CodeRabbit

  • New Features

    • Added ability to hide message history before a specific timestamp when adding members to a channel; this setting takes precedence over the existing history-hiding option.
  • Tests

    • Added unit tests verifying that the hide-before timestamp is sent, honored, and takes precedence over the legacy flag.
  • Documentation

    • Updated upcoming changes/changelog to announce the new option.

✏️ Tip: You can customize this high-level summary in your review settings.

Adds the `hideHistoryBefore` parameter to the `addMembers` and `addChannelMembers` methods.

This allows specifying a timestamp before which channel history should be hidden for newly added members. When `hideHistoryBefore` is provided, it takes precedence over the existing `hideHistory` boolean flag.

The change is propagated through the client, channel, and API layers, and new tests are added to verify the functionality.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 4, 2025

Walkthrough

Adds an optional hideHistoryBefore DateTime parameter to member-addition APIs (Channel.addMembers → StreamChatClient.addChannelMembers → Channel API). The parameter is included in the outbound payload as hide_history_before when provided and takes precedence over the existing hideHistory flag.

Changes

Cohort / File(s) Summary
API Layer
packages/stream_chat/lib/src/core/api/channel_api.dart
Added DateTime? hideHistoryBefore to addMembers; payload now includes hide_history_before (UTC ISO) when provided, otherwise falls back to hide_history. message is included only if non-null.
Client Layer
packages/stream_chat/lib/src/client/client.dart, packages/stream_chat/lib/src/client/channel.dart
Added optional hideHistoryBefore parameter to StreamChatClient.addChannelMembers and Channel.addMembers; parameter forwarded to API without changing other behavior.
Tests
packages/stream_chat/test/src/client/channel_test.dart, packages/stream_chat/test/src/client/client_test.dart, packages/stream_chat/test/src/core/api/channel_api_test.dart
Added tests asserting hideHistoryBefore is propagated through Channel → Client → API, included in the POST payload as hide_history_before, and that it takes precedence over hideHistory when both provided.
Changelog
packages/stream_chat/CHANGELOG.md
Added entry announcing hideHistoryBefore support for Channel.addMembers and Client.addChannelMembers.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Inspect channel_api.dart payload construction to ensure correct UTC ISO formatting and key naming (hide_history_before) and fallback behavior.
  • Verify parameter forwarding in client.dart and channel.dart keeps existing defaults and doesn't alter call semantics.
  • Review added tests for completeness and correctness (mock expectations, assertions, and coverage of precedence case).

Suggested reviewers

  • renefloor

Poem

🐰 I hop with timestamp bright,
New members join at morning light,
Histories hidden, fences drawn,
Before the clock, the past is gone,
Hooray — a tidy, timely sight!

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding hideHistoryBefore parameter to addMembers methods.
Linked Issues check ✅ Passed The pull request fully implements the requirement from FLU-340 by adding hideHistoryBefore support to addMembers and addChannelMembers with proper precedence over hideHistory.
Out of Scope Changes check ✅ Passed All changes are directly related to implementing hideHistoryBefore support for addMembers; no out-of-scope modifications detected.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/hide-history-before

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.

❤️ Share

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

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
packages/stream_chat/test/src/core/api/channel_api_test.dart (1)

412-492: addMembers payload and precedence semantics are well covered

The two new tests correctly assert that:

  • hide_history_before is included when hideHistoryBefore is provided, and
  • when both hideHistory and hideHistoryBefore are passed, the payload only carries hide_history_before, enforcing the documented precedence.

Structure aligns with existing tests; nothing blocking here.

If you touch this area again, you could factor the common setup (channelId, channelType, memberIds, message, hideHistoryBefore) into a small helper to reduce duplication across the two tests, but it's not necessary for this PR.

packages/stream_chat/test/src/client/client_test.dart (1)

1918-1960: LGTM! Test properly validates the hideHistoryBefore parameter.

The test is well-structured and follows the existing patterns in the file. It correctly:

  • Mocks the API call with the hideHistoryBefore parameter
  • Invokes the client method with the parameter
  • Verifies the response
  • Confirms the API was called exactly once with the correct arguments

Optional: Consider using a relative date like DateTime.now().subtract(const Duration(days: 30)) instead of the hardcoded '2024-01-01T00:00:00Z' for slightly more flexibility. However, hardcoded dates are perfectly acceptable for tests as they ensure reproducibility.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between ba177ae and dfd1054.

📒 Files selected for processing (7)
  • packages/stream_chat/CHANGELOG.md (1 hunks)
  • packages/stream_chat/lib/src/client/channel.dart (2 hunks)
  • packages/stream_chat/lib/src/client/client.dart (1 hunks)
  • packages/stream_chat/lib/src/core/api/channel_api.dart (1 hunks)
  • packages/stream_chat/test/src/client/channel_test.dart (1 hunks)
  • packages/stream_chat/test/src/client/client_test.dart (1 hunks)
  • packages/stream_chat/test/src/core/api/channel_api_test.dart (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: stream_chat_flutter
  • GitHub Check: analyze_legacy_versions
🔇 Additional comments (5)
packages/stream_chat/lib/src/client/client.dart (1)

1263-1278: addChannelMembers propagation of hideHistoryBefore is correct and backward‑compatible

The new optional hideHistoryBefore parameter is added in a backward‑compatible way and correctly forwarded to _chatApi.channel.addMembers while preserving existing hideHistory behavior when it’s null. No issues found.

packages/stream_chat/lib/src/core/api/channel_api.dart (1)

205-227: ChannelApi.addMembers correctly encodes hideHistoryBefore precedence over hideHistory

The updated signature and payload logic cleanly ensure that when hideHistoryBefore is non‑null, only hide_history_before is sent; otherwise hide_history is used, matching the documented precedence without breaking existing callers. Looks solid.

packages/stream_chat/CHANGELOG.md (1)

1-7: Changelog entry accurately documents new hideHistoryBefore behavior

The “Upcoming” section clearly explains the new parameter, its purpose, and its precedence over hideHistory, in line with the implementation.

packages/stream_chat/lib/src/client/channel.dart (1)

1573-1588: Channel.addMembers surface mirrors client/API changes correctly

The channel‑level addMembers now exposes hideHistoryBefore and correctly forwards it to addChannelMembers, keeping behavior unchanged when null. Public API remains backward‑compatible while enabling the new capability.

packages/stream_chat/test/src/client/channel_test.dart (1)

2689-2734: Channel.addMembers forwards hideHistoryBefore correctly

This test cleanly exercises the Channel wrapper, ensuring hideHistoryBefore is passed through to client.addChannelMembers and the response is wired as expected. It mirrors the existing hideHistory test and looks good.

@codecov
Copy link

codecov bot commented Dec 4, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 64.62%. Comparing base (ba177ae) to head (1170398).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2459   +/-   ##
=======================================
  Coverage   64.61%   64.62%           
=======================================
  Files         420      420           
  Lines       26210    26215    +5     
=======================================
+ Hits        16936    16941    +5     
  Misses       9274     9274           

☔ 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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/stream_chat/lib/src/core/api/channel_api.dart (1)

206-223: hideHistoryBefore handling and precedence look correct; minor consistency/readability nits only

  • The new hideHistoryBefore parameter and the switch expression correctly ensure that only one of hide_history_before (UTC ISO) or hide_history is sent, with the former taking precedence. This matches the stated API contract.
  • Conditional inclusion of message is nice and avoids sending explicit nulls. One small consistency nit: other methods in this class (e.g. inviteChannelMembers, acceptChannelInvite) still send 'message': message unconditionally. Consider standardizing either on conditional inclusion or always-present keys across these APIs for predictability, but this is non-blocking.
  • If the team tends to prefer simpler conditionals over pattern switch for map literals, you could also express this as a straightforward if (hideHistoryBefore != null) ... else ...; current form is fine if everyone is comfortable with pattern-switch style.
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between dfd1054 and 1170398.

📒 Files selected for processing (2)
  • packages/stream_chat/lib/src/core/api/channel_api.dart (1 hunks)
  • packages/stream_chat/test/src/core/api/channel_api_test.dart (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
  • GitHub Check: stream_chat_localizations
  • GitHub Check: stream_chat
  • GitHub Check: stream_chat_flutter_core
  • GitHub Check: stream_chat_persistence
  • GitHub Check: stream_chat_flutter
  • GitHub Check: test
  • GitHub Check: build (android)
  • GitHub Check: build (ios)
  • GitHub Check: analyze_legacy_versions
🔇 Additional comments (2)
packages/stream_chat/test/src/core/api/channel_api_test.dart (2)

412-448: Good coverage for hideHistoryBefore payload shape

This test cleanly verifies that when hideHistoryBefore is provided, the request data contains add_members, message, and hide_history_before in UTC ISO format, and nothing extra. It mirrors the production conversion logic and keeps the expectations tight around the payload and response.


450-489: Nice precedence test for hideHistoryBefore over hideHistory

This test correctly exercises the case where both hideHistory and hideHistoryBefore are passed and asserts that only hide_history_before appears in the payload. Because the stubbed data map excludes hide_history, the test will fail if the implementation ever includes both keys, so it robustly protects the intended precedence behavior.

@xsahil03x xsahil03x merged commit 3e517e4 into master Dec 4, 2025
19 checks passed
@xsahil03x xsahil03x deleted the feat/hide-history-before branch December 4, 2025 14:36
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.

3 participants