Skip to content

Fix offline persisted drafts not cleared on logout#6372

Merged
VelikovPetar merged 1 commit intov6from
bug/AND-1150_fix_drafts_not_cleared_on_logout
Apr 16, 2026
Merged

Fix offline persisted drafts not cleared on logout#6372
VelikovPetar merged 1 commit intov6from
bug/AND-1150_fix_drafts_not_cleared_on_logout

Conversation

@VelikovPetar
Copy link
Copy Markdown
Contributor

@VelikovPetar VelikovPetar commented Apr 16, 2026

Goal

We were not clearing the drafts offline storage on user logout. This resulted in a stuck draft message between sessions.

Implementation

Clear the drafts table on logout (same as all other tables)

Testing

  1. Create a draft (enter channel, write a message (don't send), exit channel)
  2. Re-enter same channel and send the message
  3. Logout
  4. Login
  5. The Draft should NOT be present in the channel

Summary by CodeRabbit

  • New Features

    • Added draft message cleanup to the repository clearing operation, ensuring draft messages are properly removed along with other cached data.
  • Tests

    • Added unit test to verify draft message deletion during repository clearing.

@VelikovPetar VelikovPetar added the pr:bug Bug fix label Apr 16, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 16, 2026

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.

🎉 Great job! This PR is ready for review.

@github-actions
Copy link
Copy Markdown
Contributor

SDK Size Comparison 📏

SDK Before After Difference Status
stream-chat-android-client 5.26 MB 5.26 MB 0.00 MB 🟢
stream-chat-android-offline 5.49 MB 5.49 MB 0.00 MB 🟢
stream-chat-android-ui-components 10.64 MB 10.64 MB 0.00 MB 🟢
stream-chat-android-compose 12.87 MB 12.87 MB 0.00 MB 🟢

@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
66.7% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@VelikovPetar VelikovPetar marked this pull request as ready for review April 16, 2026 09:16
@VelikovPetar VelikovPetar requested a review from a team as a code owner April 16, 2026 09:16
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 16, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 8f9a8c54-d582-43e8-a402-8b620594b2aa

📥 Commits

Reviewing files that changed from the base of the PR and between 0885f94 and 136e6da.

📒 Files selected for processing (4)
  • stream-chat-android-offline/api/stream-chat-android-offline.api
  • stream-chat-android-offline/src/main/java/io/getstream/chat/android/offline/repository/domain/message/internal/DatabaseMessageRepository.kt
  • stream-chat-android-offline/src/main/java/io/getstream/chat/android/offline/repository/domain/message/internal/MessageDao.kt
  • stream-chat-android-offline/src/test/java/io/getstream/chat/android/offline/repository/MessageRepositoryTests.kt

Walkthrough

The changes add functionality to delete all draft messages from the offline repository. A new DAO method deleteAllDrafts() is added to query and remove all draft message records, the repository's clear() method is updated to invoke this deletion alongside existing cleanup operations, and a corresponding test verifies the new behavior.

Changes

Cohort / File(s) Summary
Draft Message Deletion
stream-chat-android-offline/src/main/java/.../repository/domain/message/internal/MessageDao.kt, stream-chat-android-offline/src/main/java/.../repository/domain/message/internal/DatabaseMessageRepository.kt, stream-chat-android-offline/api/stream-chat-android-offline.api
Added new deleteAllDrafts() DAO method with Room query to delete from draft message table; updated DatabaseMessageRepository.clear() to invoke this method alongside existing message and reply cleanup; API surface updated to reflect new method signature.
Testing
stream-chat-android-offline/src/test/java/.../repository/MessageRepositoryTests.kt
Added unit test to verify DatabaseMessageRepository.clear() invokes both deleteAll() and deleteAllDrafts() on message DAO.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 Hoppy news: drafts now clear with glee,
The deleteAllDrafts() sets messages free,
A DAO query, simple and clean,
The best cleanup routine we've seen!

🚥 Pre-merge checks | ✅ 2 | ❌ 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 (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main bug fix: drafts not being cleared on logout.
Description check ✅ Passed The description covers Goal and Implementation sections well, but omits several template sections like UI Changes, Testing details, and Contributor Checklist requirements.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch bug/AND-1150_fix_drafts_not_cleared_on_logout

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.

@VelikovPetar VelikovPetar merged commit aa5a191 into v6 Apr 16, 2026
20 of 23 checks passed
@VelikovPetar VelikovPetar deleted the bug/AND-1150_fix_drafts_not_cleared_on_logout branch April 16, 2026 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr:bug Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants