Better thread last seen logic#1778
Conversation
# Conflicts: # app/src/main/java/org/thoughtcrime/securesms/configs/ConfigToDatabaseSync.kt # app/src/main/java/org/thoughtcrime/securesms/database/ThreadDatabase.java
# Conflicts: # app/src/main/java/org/session/libsession/utilities/TextSecurePreferences.kt # app/src/main/java/org/session/libsession/utilities/recipients/RecipientData.kt # app/src/main/java/org/thoughtcrime/securesms/auth/AuthAwareComponents.kt # app/src/main/java/org/thoughtcrime/securesms/configs/ConfigToDatabaseSync.kt # app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt # app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationLoader.kt # app/src/main/java/org/thoughtcrime/securesms/database/MmsDatabase.kt # app/src/main/java/org/thoughtcrime/securesms/database/MmsSmsDatabase.java # app/src/main/java/org/thoughtcrime/securesms/database/SmsDatabase.java # app/src/main/java/org/thoughtcrime/securesms/database/Storage.kt # app/src/main/java/org/thoughtcrime/securesms/database/ThreadDatabase.java # app/src/main/java/org/thoughtcrime/securesms/database/helpers/SQLCipherOpenHelper.java # app/src/main/java/org/thoughtcrime/securesms/dependencies/OnAppStartupComponents.kt # app/src/main/java/org/thoughtcrime/securesms/home/HomeActivity.kt # app/src/main/java/org/thoughtcrime/securesms/notifications/AndroidAutoReplyReceiver.kt # app/src/main/java/org/thoughtcrime/securesms/notifications/MarkReadProcessor.kt # app/src/main/java/org/thoughtcrime/securesms/notifications/MarkReadReceiver.kt # app/src/main/java/org/thoughtcrime/securesms/service/ExpiringMessageManager.kt
There was a problem hiding this comment.
Pull request overview
This PR is a significant refactoring that moves the thread last seen logic from being database-based to config-based. The core changes include:
Changes:
- Thread
lastSeenis now fully managed by the config system, removing the need for the thread table to keep it in sync - Unread message counts are now computed based on the config's last seen when querying threads
- Automatic message read handling (receipts, expiration timers) is now done by listening to config changes via
MarkReadProcessoras anAuthAwareComponent - Added
isOutgoingvirtual column to SMS/MMS databases to eliminate bitmasking logic - Removed the need to call
threadDb.update()- all thread data is now computed using the latest data
Reviewed changes
Copilot reviewed 41 out of 41 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| Storage.kt | Replaces markConversationAsRead with updateConversationLastSeenIfNeeded, manages last seen via config |
| StorageProtocol.kt | Updates interface to reflect new config-based last seen management |
| ThreadDatabase.java | Removes thread update/sync logic, reduces responsibility to basic CRUD operations |
| ThreadDatabaseExt.kt | New file with queryThreads function that computes thread data from config + DB, includes threadContainsOutgoingMessage helper |
| SmsDatabase.java, MmsDatabase.kt | Adds IS_OUTGOING virtual column, updates message read tracking |
| SmsDatabaseExt.kt | New extension with setMessagesRead implementation |
| MarkReadProcessor.kt | Now implements AuthAwareComponent, listens to config changes and processes mark-read automatically |
| SharedConfigUtils.kt | Adds utility functions for config operations: get, erase, getOrConstructConvo |
| Various notification receivers | Updated to use new updateConversationLastSeenIfNeeded API |
| Test files | Updated to use new Contact data structure with configData parameter |
| RecipientData.kt | Contact now wraps config data directly instead of duplicating fields |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
app/src/main/java/org/thoughtcrime/securesms/database/ThreadDatabaseExt.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/org/thoughtcrime/securesms/database/ThreadDatabaseExt.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/org/thoughtcrime/securesms/home/HomeDiffUtil.kt
Outdated
Show resolved
Hide resolved
...houghtcrime/securesms/conversation/disappearingmessages/DisappearingMessagesViewModelTest.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/org/thoughtcrime/securesms/database/MmsDatabase.kt
Outdated
Show resolved
Hide resolved
# Conflicts: # app/src/main/java/org/thoughtcrime/securesms/home/HomeActivity.kt
# Conflicts: # app/src/main/java/org/session/libsession/messaging/open_groups/OpenGroup.kt
# Conflicts: # app/src/main/java/org/session/libsession/database/StorageProtocol.kt # app/src/main/java/org/thoughtcrime/securesms/database/MmsSmsDatabase.java # app/src/main/java/org/thoughtcrime/securesms/webrtc/CallManager.kt # app/src/main/java/org/thoughtcrime/securesms/webrtc/WebRtcCallBridge.kt
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 60 out of 60 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
app/src/main/java/org/thoughtcrime/securesms/notifications/DeleteNotificationReceiver.kt
Show resolved
Hide resolved
app/src/main/java/org/thoughtcrime/securesms/home/ConversationOptionsBottomSheet.kt
Show resolved
Hide resolved
| import org.thoughtcrime.securesms.database.RecipientSettingsDatabase | ||
| import org.thoughtcrime.securesms.database.SmsDatabase | ||
| import org.thoughtcrime.securesms.database.ThreadDatabase | ||
| import org.thoughtcrime.securesms.database.model.GroupThreadStatus |
There was a problem hiding this comment.
Unused import: SmsDatabase_Factory is imported but not referenced in this file. Please remove it to keep imports clean.
| import org.thoughtcrime.securesms.database.model.GroupThreadStatus |
This PR moves most the last seen logic of messages onto thread level:
lastSeenis mainly sourced from the config system, a copy is saved into local db so that ancient times that would have been rejected by the config system can be saved in the dbisOutgoingvirtual column to sms/mms database so we don't have to do the crazy bitmasking stuffthreadDb.updateanymore: now every piece of data is computed using latest data