-
Notifications
You must be signed in to change notification settings - Fork 781
Fixing notifications not being dismissed when read from other devices #4129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…aining the event is no longer the latest - use explict returns constants to attempt to add more documentation - queries for the existence of the event in all of the chunk history and if a read receipt exists in the latest chunk (which it should if a user has just read on another client) which allows us to mark old notifications events as read
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That a really good catch, thanks!
I have not tested it, but I understand the idea.
See my 2 small remarks.
@@ -23,6 +23,9 @@ import org.matrix.android.sdk.internal.database.model.TimelineEventEntity | |||
import io.realm.Realm | |||
import io.realm.RealmConfiguration | |||
|
|||
private const val MARK_OLD_EVENT_AS_READ = true | |||
private const val MARK_UNREAD_DUE_TO_FASTLANE = false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure declaring const for boolean returned value increases the readability of the code. Maybe a good comment is better?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 I think this is a sign that the handleMissingEvent
is the wrong name, renaming to hasReadMissingEvent
allows us to infer the return result is has read
or has not read
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | ||
|
||
private fun Realm.hasReadReceiptInLatestChunk(latestChunkEntity: ChunkEntity, roomId: String, userId: String) : Boolean { | ||
return ReadReceiptEntity.where(this, roomId, userId).findFirst()?.let { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: The code is OK, but maybe use named arguments for roomId and userId to avoid confusion, since the types are the same (String)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💯 will do
4a51583
to
c72f668
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the update! It's more readable to me now!
Fixes #3347 and #523
Our notification dismissing works by matching the currently held notification events to the latest timeline chunk for the room, this presents a problem when the next chunk is created which doesn't reference those original notification events, which then presents itself as notifications not being dismissed when read from other sessions.
The fix is to check the existence of missing events against the entire chunk history if there's also a read receipt event in the latest chunk.
Here's the worlds least exciting gif... notice the element icon in the top