mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-23 01:45:52 +03:00
Using extensions for Boolean? type
This commit is contained in:
parent
abd25c2292
commit
9ecf12a7ba
2 changed files with 5 additions and 2 deletions
|
@ -35,6 +35,7 @@ import kotlinx.coroutines.flow.map
|
|||
import kotlinx.coroutines.flow.onEach
|
||||
import kotlinx.coroutines.flow.sample
|
||||
import kotlinx.coroutines.launch
|
||||
import org.matrix.android.sdk.api.extensions.orFalse
|
||||
import org.matrix.android.sdk.api.session.Session
|
||||
import org.matrix.android.sdk.api.util.toMatrixItem
|
||||
|
||||
|
@ -74,7 +75,7 @@ class LocationSharingViewModel @AssistedInject constructor(
|
|||
}
|
||||
|
||||
private fun updatePin(isUserPin: Boolean? = true) {
|
||||
if (isUserPin == true) {
|
||||
if (isUserPin.orFalse()) {
|
||||
locationPinProvider.create(userId = session.myUserId) {
|
||||
updatePinDrawableInState(it)
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ import android.graphics.drawable.Drawable
|
|||
import androidx.annotation.StringRes
|
||||
import com.airbnb.mvrx.MavericksState
|
||||
import im.vector.app.R
|
||||
import org.matrix.android.sdk.api.extensions.orTrue
|
||||
import org.matrix.android.sdk.api.util.MatrixItem
|
||||
|
||||
enum class LocationSharingMode(@StringRes val titleRes: Int) {
|
||||
|
@ -47,5 +48,6 @@ fun LocationSharingViewState.toMapState() = MapState(
|
|||
userLocationData = lastKnownUserLocation,
|
||||
pinId = DEFAULT_PIN_ID,
|
||||
pinDrawable = null,
|
||||
showPin = areTargetAndUserLocationEqual == false
|
||||
// show the map pin only when target location and user location are not equal
|
||||
showPin = areTargetAndUserLocationEqual.orTrue().not()
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue