fix: update last seen if later than current

This commit is contained in:
0x330a 2023-05-24 14:12:49 +10:00
parent bd81869f9a
commit c5299c1010
No known key found for this signature in database
GPG Key ID: 267811D6E6A2698C
3 changed files with 11 additions and 3 deletions

View File

@ -739,7 +739,10 @@ class MmsDatabase(context: Context, databaseHelper: SQLCipherOpenHelper) : Messa
) )
} }
with (get(context).threadDatabase()) { with (get(context).threadDatabase()) {
val lastSeen = getLastSeenAndHasSent(threadId).first()
if (lastSeen < message.sentTimeMillis) {
setLastSeen(threadId, message.sentTimeMillis) setLastSeen(threadId, message.sentTimeMillis)
}
setHasSent(threadId, true) setHasSent(threadId, true)
if (runThreadUpdate) { if (runThreadUpdate) {
update(threadId, true, true) update(threadId, true, true)

View File

@ -564,7 +564,10 @@ public class SmsDatabase extends MessagingDatabase {
if (runThreadUpdate) { if (runThreadUpdate) {
DatabaseComponent.get(context).threadDatabase().update(threadId, true, true); DatabaseComponent.get(context).threadDatabase().update(threadId, true, true);
} }
long lastSeen = DatabaseComponent.get(context).threadDatabase().getLastSeenAndHasSent(threadId).first();
if (lastSeen < message.getSentTimestampMillis()) {
DatabaseComponent.get(context).threadDatabase().setLastSeen(threadId, message.getSentTimestampMillis()); DatabaseComponent.get(context).threadDatabase().setLastSeen(threadId, message.getSentTimestampMillis());
}
DatabaseComponent.get(context).threadDatabase().setHasSent(threadId, true); DatabaseComponent.get(context).threadDatabase().setHasSent(threadId, true);

View File

@ -482,7 +482,9 @@ open class Storage(context: Context, helper: SQLCipherOpenHelper, private val co
is Conversation.Community -> getThreadIdFor("",null, "${conversation.baseCommunityInfo.baseUrl}.${conversation.baseCommunityInfo.room}", createThread = false) is Conversation.Community -> getThreadIdFor("",null, "${conversation.baseCommunityInfo.baseUrl}.${conversation.baseCommunityInfo.room}", createThread = false)
} }
if (threadId != null) { if (threadId != null) {
if (conversation.lastRead > getLastSeen(threadId)) {
markConversationAsRead(threadId, conversation.lastRead) markConversationAsRead(threadId, conversation.lastRead)
}
updateThread(threadId, false) updateThread(threadId, false)
} }
} }