Skip to content

Commit 778dab7

Browse files
committed
Cleanup and safer Json model.
1 parent 8e0c503 commit 778dab7

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed

vector-config/src/main/java/im/vector/app/config/Config.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,10 @@ object Config {
4242
const val ENABLE_LOCATION_SHARING = true
4343
const val LOCATION_MAP_TILER_KEY = "fU3vlMsMn4Jb6dnEIFsx"
4444

45-
/// Whether to read the `io.element.functional_members` state event
46-
// and exclude any service members when computing a room's name and avatar.
45+
/**
46+
* Whether to read the `io.element.functional_members` state event
47+
* and exclude any service members when computing a room's name and avatar.
48+
*/
4749
const val SUPPORT_FUNCTIONAL_MEMBERS = true
4850

4951
/**

vector/src/main/java/im/vector/app/features/room/FunctionalMembersState.kt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,13 @@ private const val FUNCTIONAL_MEMBERS_STATE_EVENT_TYPE = "io.element.functional_m
2626

2727
@JsonClass(generateAdapter = true)
2828
data class FunctionalMembersContent(
29-
@Json(name = "service_members") val userIds: List<String>
29+
@Json(name = "service_members") val userIds: List<String>? = null
3030
)
3131

3232
fun StateService.getFunctionalMembers(): List<String> {
33-
return getStateEvent(FUNCTIONAL_MEMBERS_STATE_EVENT_TYPE, QueryStringValue.IsEmpty)?.let {
34-
it.content.toModel<FunctionalMembersContent>()?.userIds
35-
}.orEmpty()
33+
return getStateEvent(FUNCTIONAL_MEMBERS_STATE_EVENT_TYPE, QueryStringValue.IsEmpty)
34+
?.content
35+
?.toModel<FunctionalMembersContent>()
36+
?.userIds
37+
.orEmpty()
3638
}

vector/src/main/java/im/vector/app/features/room/VectorRoomDisplayNameFallbackProvider.kt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,12 @@ class VectorRoomDisplayNameFallbackProvider @Inject constructor(
3232

3333
override fun excludedUserIds(roomId: String): List<String> {
3434
if (!Config.SUPPORT_FUNCTIONAL_MEMBERS) return emptyList()
35-
return activeSessionHolder.get().getSafeActiveSession()
36-
?.getRoom(roomId)?.let { room ->
37-
room.stateService().getFunctionalMembers()
38-
}.orEmpty()
35+
return activeSessionHolder.get()
36+
.getSafeActiveSession()
37+
?.getRoom(roomId)
38+
?.stateService()
39+
?.getFunctionalMembers()
40+
.orEmpty()
3941
}
4042

4143
override fun getNameForRoomInvite(): String {

0 commit comments

Comments
 (0)