Use orEmpty()
This commit is contained in:
parent
1070c23608
commit
b888d13e62
@ -1204,7 +1204,7 @@ internal class DefaultVerificationService @Inject constructor(
|
|||||||
Timber.i("## Requesting verification to user: $otherUserId with device list $otherDevices")
|
Timber.i("## Requesting verification to user: $otherUserId with device list $otherDevices")
|
||||||
|
|
||||||
val targetDevices = otherDevices ?: cryptoStore.getUserDevices(otherUserId)
|
val targetDevices = otherDevices ?: cryptoStore.getUserDevices(otherUserId)
|
||||||
?.values?.map { it.deviceId } ?: emptyList()
|
?.values?.map { it.deviceId }.orEmpty()
|
||||||
|
|
||||||
val requestsForUser = pendingRequests.getOrPut(otherUserId) { mutableListOf() }
|
val requestsForUser = pendingRequests.getOrPut(otherUserId) { mutableListOf() }
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@ internal class DefaultTimelineService @AssistedInject constructor(@Assisted priv
|
|||||||
.sort(TimelineEventEntityFields.DISPLAY_INDEX, Sort.ASCENDING)
|
.sort(TimelineEventEntityFields.DISPLAY_INDEX, Sort.ASCENDING)
|
||||||
.findAll()
|
.findAll()
|
||||||
?.mapNotNull { timelineEventMapper.map(it).takeIf { it.root.isImageMessage() || it.root.isVideoMessage() } }
|
?.mapNotNull { timelineEventMapper.map(it).takeIf { it.root.isImageMessage() || it.root.isVideoMessage() } }
|
||||||
?: emptyList()
|
.orEmpty()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ internal class RoomTypingUsersHandler @Inject constructor(@UserId private val us
|
|||||||
|
|
||||||
fun handle(realm: Realm, roomId: String, ephemeralResult: RoomSyncHandler.EphemeralResult?) {
|
fun handle(realm: Realm, roomId: String, ephemeralResult: RoomSyncHandler.EphemeralResult?) {
|
||||||
val roomMemberHelper = RoomMemberHelper(realm, roomId)
|
val roomMemberHelper = RoomMemberHelper(realm, roomId)
|
||||||
val typingIds = ephemeralResult?.typingUserIds?.filter { it != userId } ?: emptyList()
|
val typingIds = ephemeralResult?.typingUserIds?.filter { it != userId }.orEmpty()
|
||||||
val senderInfo = typingIds.map { userId ->
|
val senderInfo = typingIds.map { userId ->
|
||||||
val roomMemberSummaryEntity = roomMemberHelper.getLastRoomMember(userId)
|
val roomMemberSummaryEntity = roomMemberHelper.getLastRoomMember(userId)
|
||||||
SenderInfo(
|
SenderInfo(
|
||||||
|
@ -37,6 +37,6 @@ internal class DefaultTypingUsersTracker @Inject constructor() : TypingUsersTrac
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun getTypingUsers(roomId: String): List<SenderInfo> {
|
override fun getTypingUsers(roomId: String): List<SenderInfo> {
|
||||||
return typingUsers[roomId] ?: emptyList()
|
return typingUsers[roomId].orEmpty()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -138,7 +138,7 @@ internal class WidgetManager @Inject constructor(private val integrationManager:
|
|||||||
): LiveData<List<Widget>> {
|
): LiveData<List<Widget>> {
|
||||||
val widgetsAccountData = accountDataDataSource.getLiveAccountDataEvent(UserAccountDataTypes.TYPE_WIDGETS)
|
val widgetsAccountData = accountDataDataSource.getLiveAccountDataEvent(UserAccountDataTypes.TYPE_WIDGETS)
|
||||||
return Transformations.map(widgetsAccountData) {
|
return Transformations.map(widgetsAccountData) {
|
||||||
it.getOrNull()?.mapToWidgets(widgetTypes, excludedTypes) ?: emptyList()
|
it.getOrNull()?.mapToWidgets(widgetTypes, excludedTypes).orEmpty()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -204,9 +204,9 @@ class RoomDirectoryViewModel @AssistedInject constructor(@Assisted initialState:
|
|||||||
Timber.w("Try to join an already joining room. Should not happen")
|
Timber.w("Try to join an already joining room. Should not happen")
|
||||||
return@withState
|
return@withState
|
||||||
}
|
}
|
||||||
val viaServers = state.roomDirectoryData.homeServer?.let {
|
val viaServers = state.roomDirectoryData.homeServer
|
||||||
listOf(it)
|
?.let { listOf(it) }
|
||||||
} ?: emptyList()
|
.orEmpty()
|
||||||
session.joinRoom(action.roomId, viaServers = viaServers, callback = object : MatrixCallback<Unit> {
|
session.joinRoom(action.roomId, viaServers = viaServers, callback = object : MatrixCallback<Unit> {
|
||||||
override fun onSuccess(data: Unit) {
|
override fun onSuccess(data: Unit) {
|
||||||
// We do not update the joiningRoomsIds here, because, the room is not joined yet regarding the sync data.
|
// We do not update the joiningRoomsIds here, because, the room is not joined yet regarding the sync data.
|
||||||
|
@ -106,7 +106,7 @@ class UserListController @Inject constructor(private val session: Session,
|
|||||||
currentState.getSelectedMatrixId(),
|
currentState.getSelectedMatrixId(),
|
||||||
currentState.searchTerm,
|
currentState.searchTerm,
|
||||||
// to avoid showing twice same user in known and suggestions
|
// to avoid showing twice same user in known and suggestions
|
||||||
currentState.knownUsers.invoke()?.map { it.userId } ?: emptyList()
|
currentState.knownUsers.invoke()?.map { it.userId }.orEmpty()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user