Cleanup and add changelog

This commit is contained in:
Benoit Marty 2021-09-24 15:38:08 +02:00
parent 9b02704d5b
commit 3287980109
2 changed files with 26 additions and 28 deletions

1
changelog.d/4057.feature Normal file
View File

@ -0,0 +1 @@
Improve space invite bottom sheet

View File

@ -61,38 +61,35 @@ class SpaceInviteBottomSheetViewModel @AssistedInject constructor(
peopleYouKnow = Success(peopleYouKnow) peopleYouKnow = Success(peopleYouKnow)
) )
} }
refreshInviteSummaryIfNeeded(roomSummary) if (roomSummary.membership == Membership.INVITE) {
getLatestRoomSummary(roomSummary)
}
} }
} }
private fun refreshInviteSummaryIfNeeded(roomSummary: RoomSummary) { /**
if (roomSummary.membership == Membership.INVITE) { * Try to request the room summary api to get more info
// we can try to query the room summary api to get more info? */
viewModelScope.launch(Dispatchers.IO) { private fun getLatestRoomSummary(roomSummary: RoomSummary) {
when (val peekResult = tryOrNull { session.peekRoom(roomSummary.roomId) }) { viewModelScope.launch(Dispatchers.IO) {
is PeekResult.Success -> { val peekResult = tryOrNull { session.peekRoom(roomSummary.roomId) } as? PeekResult.Success ?: return@launch
setState { setState {
copy( copy(
summary = Success( summary = Success(
roomSummary.copy( roomSummary.copy(
joinedMembersCount = peekResult.numJoinedMembers, joinedMembersCount = peekResult.numJoinedMembers,
// it's also possible that the name/avatar did change since the invite.. // it's also possible that the name/avatar did change since the invite..
// if it's null keep the old one as summary API might not be available // if it's null keep the old one as summary API might not be available
// and peek result could be null for other reasons (not peekable) // and peek result could be null for other reasons (not peekable)
avatarUrl = peekResult.avatarUrl ?: roomSummary.avatarUrl, avatarUrl = peekResult.avatarUrl ?: roomSummary.avatarUrl,
displayName = peekResult.name ?: roomSummary.displayName, displayName = peekResult.name ?: roomSummary.displayName,
topic = peekResult.topic ?: roomSummary.topic topic = peekResult.topic ?: roomSummary.topic
// maybe use someMembers field later? // maybe use someMembers field later?
) )
) )
) )
}
}
else -> {
// nop
}
}
} }
} }
} }