-
Notifications
You must be signed in to change notification settings - Fork 754
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
Check user power level before sharing live location (PSG-620) #6587
Check user power level before sharing live location (PSG-620) #6587
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.
Nice work, some remarks.
.setTitle(R.string.live_location_not_enough_permission_dialog_title) | ||
.setMessage(R.string.live_location_not_enough_permission_dialog_description) | ||
.setPositiveButton(R.string.ok) { dialogInterface, _ -> | ||
dialogInterface.dismiss() |
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 think this code is necessary. You can replace by
.setPositiveButton(R.string.ok, 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.
Of course, done.
checkPowerLevelsForLiveLocationSharing() | ||
} | ||
|
||
private fun checkPowerLevelsForLiveLocationSharing() { |
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.
Could be rename to observePowerLevelsForLiveLocationSharing
since this is using a Flow.
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, done.
.map { beaconInfoType -> | ||
powerLevelsHelper.isUserAllowedToSend(session.myUserId, true, beaconInfoType) | ||
} | ||
.all { isUserAllowed -> isUserAllowed } |
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.
This seems a bit strange to map twice. You can reduce to:
val canShareLiveLocation = EventType.STATE_ROOM_BEACON_INFO
.all { beaconInfoType ->
powerLevelsHelper.isUserAllowedToSend(session.myUserId, true, beaconInfoType)
}
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.
Silly mistake :) Fixed.
.all { isUserAllowed -> isUserAllowed } | ||
|
||
setState { copy(canShareLiveLocation = canShareLiveLocation) } | ||
}.launchIn(viewModelScope) |
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: You could use setOnEach
for shorter code:
PowerLevelsFlowFactory(room).createFlow()
.distinctUntilChanged()
.setOnEach {
val powerLevelsHelper = PowerLevelsHelper(it)
val canShareLiveLocation = EventType.STATE_ROOM_BEACON_INFO
.all { beaconInfoType ->
powerLevelsHelper.isUserAllowedToSend(session.myUserId, true, beaconInfoType)
}
copy(canShareLiveLocation = canShareLiveLocation)
}
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 didn't know that. Perfect, done.
@@ -3054,6 +3054,8 @@ | |||
<!-- TODO remove key --> | |||
<string name="live_location_bottom_sheet_stop_sharing" tools:ignore="UnusedResources">Stop sharing</string> | |||
<string name="live_location_bottom_sheet_last_updated_at">Updated %1$s ago</string> | |||
<string name="live_location_not_enough_permission_dialog_title">You don’t have permission to share locations</string> | |||
<string name="live_location_not_enough_permission_dialog_description">You need to have the right permissions in order to share locations in this room.</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.
Do those two wording mention live location
instead of location
? I think this is always possible to share (static) location, so this may be confusing for the user.
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 agree, replaced.
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 you fix the conflict please?
SonarCloud Quality Gate failed. |
Type of change
Content
Wha a user tries to share their live location we need to check if the user has enough power level before showing duration bottom sheet or labs flag promotion bottom sheet.
Motivation and context
Screenshots / GIFs
Tests
Tested devices
Checklist