Skip to content

Migrate getUnreadCounts response to the generated WrappedUnreadCountsResponse model - #6619

Open
gpunto wants to merge 1 commit into
developfrom
migrate/unread-counts
Open

Migrate getUnreadCounts response to the generated WrappedUnreadCountsResponse model#6619
gpunto wants to merge 1 commit into
developfrom
migrate/unread-counts

Conversation

@gpunto

@gpunto gpunto commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Goal

Migrate the getUnreadCounts response (GET /unread) from the hand-written UnreadDto family to the generated WrappedUnreadCountsResponse network model.

Part of AND-1291

Implementation

  • Add generated WrappedUnreadCountsResponse, UnreadCountsChannel, UnreadCountsChannelType, UnreadCountsThread; remove the hand-written UnreadDtos (UnreadDto/UnreadChannelDto/UnreadThreadDto/UnreadChannelByTypeDto).
  • Retype GeneralApi.getUnreadCounts() and map the generated model to the domain UnreadCounts in DomainMapping.

Testing

  • New UnreadCountsParsingTest locks the wire shape (JSON -> WrappedUnreadCountsResponse -> UnreadCounts), including the required duration, the per-team map, and date round-trips.
  • DomainMappingTest rewritten with explicit expected values (no recompute-the-mapper tautology).
  • Device-probed getUnreadCounts() on the wire: parses cleanly with populated counts, channels, and channelsByType.
  • spotlessCheck, apiCheck (no public-API change), detekt, and the full client testDebugUnitTest suite pass.

Summary by CodeRabbit

  • Bug Fixes

    • Improved handling of unread-count responses, including totals, channels, threads, channel types, and team-level counts.
    • Ensured unread data is correctly mapped from API responses, including optional and missing values.
  • Tests

    • Added coverage for parsing and mapping complete unread-count responses.
    • Updated existing unread-count tests and fixtures to reflect the current response format.

@gpunto gpunto added the pr:internal Internal changes / housekeeping label Aug 5, 2026
@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

PR checklist ✅

All required conditions are satisfied:

  • Title length is OK (or ignored by label).
  • At least one pr: label exists.
  • Sections ### Goal, ### Implementation, and ### Testing are filled, or the PR is bot-authored.
  • An issue is linked (Linear ticket or GitHub issue), or the PR is bot-authored.

🎉 Great job! This PR is ready for review.

@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

SDK Size Comparison 📏

SDK Before After Difference Status
stream-chat-android-client 5.96 MB 5.96 MB 0.00 MB 🟢
stream-chat-android-ui-components 11.25 MB 11.25 MB 0.00 MB 🟢
stream-chat-android-compose 12.73 MB 12.73 MB 0.00 MB 🟢

@gpunto
gpunto force-pushed the migrate/unread-counts branch from fb9abc3 to 6adf960 Compare August 6, 2026 09:43
@gpunto
gpunto marked this pull request as ready for review August 6, 2026 09:51
@gpunto
gpunto requested a review from a team as a code owner August 6, 2026 09:51
@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 446c2238-a8ce-4c81-aa67-76cb26610e2f

📥 Commits

Reviewing files that changed from the base of the PR and between c7496c6 and 6adf960.

📒 Files selected for processing (14)
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/endpoint/GeneralApi.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/mapping/DomainMapping.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/model/dto/UnreadDtos.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/UnreadCountsChannel.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/UnreadCountsChannelType.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/UnreadCountsThread.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/WrappedUnreadCountsResponse.kt
  • stream-chat-android-client/src/test/java/io/getstream/chat/android/client/Mother.kt
  • stream-chat-android-client/src/test/java/io/getstream/chat/android/client/api2/MoshiChatApiTest.kt
  • stream-chat-android-client/src/test/java/io/getstream/chat/android/client/api2/MoshiChatApiTestArguments.kt
  • stream-chat-android-client/src/test/java/io/getstream/chat/android/client/api2/mapping/DomainMappingTest.kt
  • stream-chat-android-client/src/test/java/io/getstream/chat/android/client/parser2/UnreadCountsParsingTest.kt
  • stream-chat-android-client/src/test/java/io/getstream/chat/android/client/parser2/UnreadDtoAdapterTest.kt
  • stream-chat-android-client/src/test/java/io/getstream/chat/android/client/parser2/testdata/UnreadDtoTestData.kt
💤 Files with no reviewable changes (3)
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/model/dto/UnreadDtos.kt
  • stream-chat-android-client/src/test/java/io/getstream/chat/android/client/parser2/testdata/UnreadDtoTestData.kt
  • stream-chat-android-client/src/test/java/io/getstream/chat/android/client/parser2/UnreadDtoAdapterTest.kt

Walkthrough

The unread-count API now returns WrappedUnreadCountsResponse and related network models. Domain mappings, fixtures, API tests, and parsing tests now use the new response structure.

Changes

Unread counts migration

Layer / File(s) Summary
Unread-count response models
stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/UnreadCounts*.kt, stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/WrappedUnreadCountsResponse.kt, stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/model/dto/UnreadDtos.kt
Added Moshi network models for wrapped unread counts and removed the legacy unread-count DTO file.
API response and domain mapping
stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/endpoint/GeneralApi.kt, stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/mapping/DomainMapping.kt
Changed getUnreadCounts() and the domain conversion functions to use the new response models and camelCase fields.
Fixtures and parsing validation
stream-chat-android-client/src/test/java/io/getstream/chat/android/client/Mother.kt, stream-chat-android-client/src/test/java/io/getstream/chat/android/client/api2/*, stream-chat-android-client/src/test/java/io/getstream/chat/android/client/api2/mapping/DomainMappingTest.kt, stream-chat-android-client/src/test/java/io/getstream/chat/android/client/parser2/UnreadCountsParsingTest.kt, stream-chat-android-client/src/test/java/io/getstream/chat/android/client/parser2/UnreadDtoAdapterTest.kt, stream-chat-android-client/src/test/java/io/getstream/chat/android/client/parser2/testdata/UnreadDtoTestData.kt
Updated unread-count fixtures and API/mapping tests, added end-to-end parsing assertions, and removed obsolete DTO adapter tests and fixtures.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

Suggested reviewers: velikovpetar

Poem

A rabbit hops through counts anew,
With wrapped-up fields in every queue.
Channels, threads, and types align,
While Moshi maps each coded line.
Tests inspect the totals bright—
New models burrow clean and right.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the migration of getUnreadCounts to the generated WrappedUnreadCountsResponse model.
Description check ✅ Passed The description covers the goal, implementation, testing, issue context, and validation results; omitted UI sections are not relevant to this SDK change.
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.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch migrate/unread-counts

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.

@sonarqubecloud

sonarqubecloud Bot commented Aug 6, 2026

Copy link
Copy Markdown

@gpunto
gpunto enabled auto-merge August 6, 2026 14:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr:internal Internal changes / housekeeping

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant