-
Notifications
You must be signed in to change notification settings - Fork 858
[Location sharing] - Update DB entity when a live is timed out (PSF-999) #6128
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
Unit Test Results124 files ±0 124 suites ±0 2m 11s ⏱️ -8s Results for commit 791d4fb. ± Comparison against base commit 9a38d59. This pull request removes 1 and adds 1 tests. Note that renamed tests count towards both.♻️ This comment has been updated with latest results. |
a8a9c7f to
b05fc76
Compare
onurays
left a comment
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.
Nice improvement. This is required to mark other users' timeout, in case of they cannot update state event because of network problems etc., right?
In fact, this was done mainly for 2 reasons:
|
bmarty
left a comment
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.
Nice improvement, thanks!
Only some minor comments.
|
|
||
| private suspend fun deactivateLiveLocationShare(params: Params) { | ||
| awaitTransaction(realmConfiguration) { realm -> | ||
| val aggregatedSummary = LiveLocationShareAggregatedSummaryEntity.getOrCreate( |
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.
Do we need a getOrCreate here? I mean if the instance is not found, does it worth creating it? I guess it will be always found, except after a clear cache maybe.
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.
You are right, I changed it in b081429
| } | ||
|
|
||
| private fun scheduleDeactivationAfterTimeout(eventId: String, roomId: String, endOfLiveTimestampMillis: Long?) { | ||
| endOfLiveTimestampMillis?.let { endOfLiveMillis -> |
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: personnally I prefer to have this first line:
endOfLiveTimestampMillis?: returnIt has the advantage to avoid to "rename" endOfLiveTimestampMillis to endOfLiveMillis and also reduce the indentation level.
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.
Yes I agree it is more readable. I changed it in cfdc18d
| endOfLiveTimestampMillis?.let { endOfLiveMillis -> | ||
| val workParams = DeactivateLiveLocationShareWorker.Params(sessionId = sessionId, eventId = eventId, roomId = roomId) | ||
| val workData = WorkerParamsFactory.toData(workParams) | ||
| val workName = DeactivateLiveLocationShareWorker.getWorkName(eventId = eventId, roomId = 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.
Thanks for using named parameters!
|
|
||
| workManagerProvider.workManager.enqueueUniqueWork( | ||
| workName, | ||
| ExistingWorkPolicy.KEEP, |
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 you should use ExistingWorkPolicy.REPLACE 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.
I have done the change in 8864a3c. But I am not sure if it will make a big difference.
| companion object { | ||
| private const val WORK_NAME_PREFIX = "DeactivateLiveLocationWork-" | ||
|
|
||
| fun getWorkName(eventId: String, roomId: String) = "${WORK_NAME_PREFIX}$eventId-$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.
I do not know if the length of the string passed for uniqueWorkName can be limited, but maybe better to be safe here:
Maybe call .md5(), so replace by:
fun getWorkName(eventId: String, roomId: String): String {
val hash = "$eventId$roomId".md5()
return "DeactivateLiveLocationWork-$hash"
}(you can keep the const WORK_NAME_PREFIX if you prefer)
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 suggestion. I updated the code, see 791d4fb
|
Kudos, SonarCloud Quality Gate passed!
|
| eventId: String, | ||
| ): LiveLocationShareAggregatedSummaryEntity? { | ||
| return LiveLocationShareAggregatedSummaryEntity.where(realm, roomId, eventId).findFirst() | ||
| } |
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.
Not for this PR, but now the line 55 could be replaced by a call to this new method.
bmarty
left a comment
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!
can be merged from my POV.
Matrix SDKIntegration Tests Results:
|








Type of change
Content
Introducing
DeactivateLiveLocationShareWorkerto set theisActivefield tofalseafter a live location share is timed out.Motivation and context
Closes #6123
It enables also auto-refresh of the message tile when on timeline view when a live has just timed out.
It will ease the request on database to find all currently active lives in a room.
Screenshots / GIFs
Tests
Tested devices
Checklist