mirror of
https://github.com/vector-im/element-android.git
synced 2024-11-16 02:05:06 +08:00
Cleanup and add changelog
This commit is contained in:
parent
9b02704d5b
commit
3287980109
1
changelog.d/4057.feature
Normal file
1
changelog.d/4057.feature
Normal file
@ -0,0 +1 @@
|
||||
Improve space invite bottom sheet
|
@ -61,38 +61,35 @@ class SpaceInviteBottomSheetViewModel @AssistedInject constructor(
|
||||
peopleYouKnow = Success(peopleYouKnow)
|
||||
)
|
||||
}
|
||||
refreshInviteSummaryIfNeeded(roomSummary)
|
||||
if (roomSummary.membership == Membership.INVITE) {
|
||||
getLatestRoomSummary(roomSummary)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun refreshInviteSummaryIfNeeded(roomSummary: RoomSummary) {
|
||||
if (roomSummary.membership == Membership.INVITE) {
|
||||
// we can try to query the room summary api to get more info?
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
when (val peekResult = tryOrNull { session.peekRoom(roomSummary.roomId) }) {
|
||||
is PeekResult.Success -> {
|
||||
setState {
|
||||
copy(
|
||||
summary = Success(
|
||||
roomSummary.copy(
|
||||
joinedMembersCount = peekResult.numJoinedMembers,
|
||||
// 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
|
||||
// and peek result could be null for other reasons (not peekable)
|
||||
avatarUrl = peekResult.avatarUrl ?: roomSummary.avatarUrl,
|
||||
displayName = peekResult.name ?: roomSummary.displayName,
|
||||
topic = peekResult.topic ?: roomSummary.topic
|
||||
// maybe use someMembers field later?
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
else -> {
|
||||
// nop
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Try to request the room summary api to get more info
|
||||
*/
|
||||
private fun getLatestRoomSummary(roomSummary: RoomSummary) {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
val peekResult = tryOrNull { session.peekRoom(roomSummary.roomId) } as? PeekResult.Success ?: return@launch
|
||||
setState {
|
||||
copy(
|
||||
summary = Success(
|
||||
roomSummary.copy(
|
||||
joinedMembersCount = peekResult.numJoinedMembers,
|
||||
// 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
|
||||
// and peek result could be null for other reasons (not peekable)
|
||||
avatarUrl = peekResult.avatarUrl ?: roomSummary.avatarUrl,
|
||||
displayName = peekResult.name ?: roomSummary.displayName,
|
||||
topic = peekResult.topic ?: roomSummary.topic
|
||||
// maybe use someMembers field later?
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user