-
Notifications
You must be signed in to change notification settings - Fork 845
added read receipts for threads #7474
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
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! The code is not compiling, can you check please? Also I have added some remarks.
| * Force the read marker to be set on the latest event. | ||
| */ | ||
| suspend fun markAsRead(params: MarkAsReadParams = MarkAsReadParams.BOTH) | ||
| suspend fun markAsRead(params: MarkAsReadParams = MarkAsReadParams.BOTH, mainTimeLineOnly: Boolean) |
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.
Maybe add default value to the new parameters to avoid API breaks.
Also can you document API change in a .sdk file for towncrier? Thanks.
| */ | ||
| internal fun updateNotificationsNew(roomId: String, realm: Realm, currentUserId: String) { | ||
| val readReceipt = findMyReadReceipt(realm, roomId, currentUserId) ?: return | ||
| val readReceipt = findMyReadReceipt(realm, roomId, currentUserId, ReadService.THREAD_ID_MAIN) ?: return |
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.
Maybe use null instead of introducing const ReadService.THREAD_ID_MAIN. Not sure it's better though.
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.
null and main values for threadId in read receipt are different cases so we can't use null here
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.
After looking deeper at this method I've realised that it needs to be changed, so it will use exact threadId instead of main
| internal fun ReadReceiptEntity.Companion.where(realm: Realm, roomId: String, userId: String): RealmQuery<ReadReceiptEntity> { | ||
| return realm.where<ReadReceiptEntity>() | ||
| .equalTo(ReadReceiptEntityFields.PRIMARY_KEY, buildPrimaryKey(roomId, userId)) | ||
| .equalTo(ReadReceiptEntityFields.USER_ID, userId) |
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.
Maybe make this fun private to avoid any mistake. I understand that only the 2 functions above have to be used now.
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've found some usages of this method, but after some closer look it appeared that these cases should use threadId also, so now there is no usages and I'll rather remove this method completely. Or is there a reason to keep it and make private even if it's not used?
| } | ||
|
|
||
| private fun buildPrimaryKey(roomId: String, userId: String) = "${roomId}_$userId" | ||
| private fun buildPrimaryKey(roomId: String, userId: String, threadId: String?) = "${roomId}_${userId}_${threadId ?: "null"}" |
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.
For compatibility I would have written
| private fun buildPrimaryKey(roomId: String, userId: String, threadId: String?) = "${roomId}_${userId}_${threadId ?: "null"}" | |
| private fun buildPrimaryKey(roomId: String, userId: String, threadId: String?): String { | |
| return if (threadId == null) { | |
| "${roomId}_${userId}" | |
| } else { | |
| "${roomId}_${userId}_${threadId}" | |
| } |
| private val readReceiptsSummaryMapper: ReadReceiptsSummaryMapper, | ||
| @UserId private val userId: String | ||
| @UserId private val userId: String, | ||
| private val homeServerCapabilitiesService: HomeServerCapabilitiesService, |
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.
Better to inject HomeServerCapabilitiesDataSource here.
| private fun ensureReadReceiptAreLoaded(realm: Realm) { | ||
| readReceiptHandler.getContentFromInitSync(roomId) | ||
| ?.also { | ||
| Timber.w("INIT_SYNC Insert when opening timeline RR for room $roomId") |
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.
Maybe just reduce the log level to d, or delete the also block.
| ) { | ||
| // First check if we have data from init sync to handle | ||
| getContentFromInitSync(roomId)?.let { | ||
| Timber.w("INIT_SYNC Insert during incremental sync RR for room $roomId") |
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.
Same remark about log level.
| .readReceipts(readReceiptsData) | ||
| .avatarRenderer(avatarRenderer) | ||
| .shouldHideReadReceipts(isFromThreadTimeLine) | ||
| .shouldHideReadReceipts(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.
Maybe shouldHideReadReceipts can be just removed. Or maybe set to something like isFromThreadTimeLine && !canUseThreadReadReceiptsAndNotifications
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.
LGTM, thanks for the update. Just a last remark about API doc.
| * Set the read receipt on the event with provided eventId. | ||
| */ | ||
| suspend fun setReadReceipt(eventId: String) | ||
| suspend fun setReadReceipt(eventId: String, threadId: 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.
Maybe add Kdoc for parameters, especially tell about the possible value THREAD_ID_MAIN for threadId.
|
SonarCloud Quality Gate failed. |








Type of change
Content
with MSC3771 we have a possibility to display read receipts for messages in a thread
Motivation and context
#6996
Screenshots / GIFs