Add braces to multiline if else
This commit is contained in:
parent
07446d2d41
commit
84202adc5b
|
@ -183,10 +183,11 @@ class NoticeEventFormatter @Inject constructor(private val activeSessionDataSour
|
|||
return event.getClearContent().toModel<RoomCreateContent>()
|
||||
?.takeIf { it.creator.isNullOrBlank().not() }
|
||||
?.let {
|
||||
if (event.isSentByCurrentUser())
|
||||
if (event.isSentByCurrentUser()) {
|
||||
sp.getString(if (event.isDm()) R.string.notice_direct_room_created_by_you else R.string.notice_room_created_by_you)
|
||||
else
|
||||
} else {
|
||||
sp.getString(if (event.isDm()) R.string.notice_direct_room_created else R.string.notice_room_created, it.creator)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -208,10 +209,11 @@ class NoticeEventFormatter @Inject constructor(private val activeSessionDataSour
|
|||
}
|
||||
|
||||
private fun formatRoomTombstoneEvent(event: Event, senderName: String?): CharSequence? {
|
||||
return if (event.isSentByCurrentUser())
|
||||
return if (event.isSentByCurrentUser()) {
|
||||
sp.getString(if (event.isDm()) R.string.notice_direct_room_update_by_you else R.string.notice_room_update_by_you)
|
||||
else
|
||||
} else {
|
||||
sp.getString(if (event.isDm()) R.string.notice_direct_room_update else R.string.notice_room_update, senderName)
|
||||
}
|
||||
}
|
||||
|
||||
private fun formatRoomTopicEvent(event: Event, senderName: String?): CharSequence? {
|
||||
|
@ -252,12 +254,13 @@ class NoticeEventFormatter @Inject constructor(private val activeSessionDataSour
|
|||
val historyVisibility = event.getClearContent().toModel<RoomHistoryVisibilityContent>()?.historyVisibility ?: return null
|
||||
|
||||
val formattedVisibility = roomHistoryVisibilityFormatter.format(historyVisibility)
|
||||
return if (event.isSentByCurrentUser())
|
||||
return if (event.isSentByCurrentUser()) {
|
||||
sp.getString(if (event.isDm()) R.string.notice_made_future_direct_room_visibility_by_you else R.string.notice_made_future_room_visibility_by_you,
|
||||
formattedVisibility)
|
||||
else
|
||||
} else {
|
||||
sp.getString(if (event.isDm()) R.string.notice_made_future_direct_room_visibility else R.string.notice_made_future_room_visibility,
|
||||
senderName, formattedVisibility)
|
||||
}
|
||||
}
|
||||
|
||||
private fun formatRoomThirdPartyInvite(event: Event, senderName: String?): CharSequence? {
|
||||
|
@ -267,21 +270,23 @@ class NoticeEventFormatter @Inject constructor(private val activeSessionDataSour
|
|||
return when {
|
||||
prevContent != null -> {
|
||||
// Revoke case
|
||||
if (event.isSentByCurrentUser())
|
||||
if (event.isSentByCurrentUser()) {
|
||||
sp.getString(if (event.isDm()) R.string.notice_direct_room_third_party_revoked_invite_by_you else R.string.notice_room_third_party_revoked_invite_by_you,
|
||||
prevContent.displayName)
|
||||
else
|
||||
} else {
|
||||
sp.getString(if (event.isDm()) R.string.notice_direct_room_third_party_revoked_invite else R.string.notice_room_third_party_revoked_invite,
|
||||
senderName, prevContent.displayName)
|
||||
}
|
||||
}
|
||||
content != null -> {
|
||||
// Invitation case
|
||||
if (event.isSentByCurrentUser())
|
||||
if (event.isSentByCurrentUser()) {
|
||||
sp.getString(if (event.isDm()) R.string.notice_direct_room_third_party_invite_by_you else R.string.notice_room_third_party_invite_by_you,
|
||||
content.displayName)
|
||||
else
|
||||
} else {
|
||||
sp.getString(if (event.isDm()) R.string.notice_direct_room_third_party_invite else R.string.notice_room_third_party_invite,
|
||||
senderName, content.displayName)
|
||||
}
|
||||
}
|
||||
else -> null
|
||||
}
|
||||
|
@ -396,17 +401,19 @@ class NoticeEventFormatter @Inject constructor(private val activeSessionDataSour
|
|||
val eventContent: RoomGuestAccessContent? = event.getClearContent().toModel()
|
||||
return when (eventContent?.guestAccess) {
|
||||
GuestAccess.CanJoin ->
|
||||
if (event.isSentByCurrentUser())
|
||||
if (event.isSentByCurrentUser()) {
|
||||
sp.getString(if (event.isDm()) R.string.notice_direct_room_guest_access_can_join_by_you else R.string.notice_room_guest_access_can_join_by_you)
|
||||
else
|
||||
} else {
|
||||
sp.getString(if (event.isDm()) R.string.notice_direct_room_guest_access_can_join else R.string.notice_room_guest_access_can_join,
|
||||
senderName)
|
||||
}
|
||||
GuestAccess.Forbidden ->
|
||||
if (event.isSentByCurrentUser())
|
||||
if (event.isSentByCurrentUser()) {
|
||||
sp.getString(if (event.isDm()) R.string.notice_direct_room_guest_access_forbidden_by_you else R.string.notice_room_guest_access_forbidden_by_you)
|
||||
else
|
||||
} else {
|
||||
sp.getString(if (event.isDm()) R.string.notice_direct_room_guest_access_forbidden else R.string.notice_room_guest_access_forbidden,
|
||||
senderName)
|
||||
}
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
@ -530,18 +537,20 @@ class NoticeEventFormatter @Inject constructor(private val activeSessionDataSour
|
|||
}
|
||||
Membership.JOIN ->
|
||||
eventContent.safeReason?.let { reason ->
|
||||
if (event.isSentByCurrentUser())
|
||||
if (event.isSentByCurrentUser()) {
|
||||
sp.getString(if (event.isDm()) R.string.notice_direct_room_join_with_reason_by_you else R.string.notice_room_join_with_reason_by_you,
|
||||
reason)
|
||||
else
|
||||
} else {
|
||||
sp.getString(if (event.isDm()) R.string.notice_direct_room_join_with_reason else R.string.notice_room_join_with_reason,
|
||||
senderDisplayName, reason)
|
||||
}
|
||||
} ?: run {
|
||||
if (event.isSentByCurrentUser())
|
||||
if (event.isSentByCurrentUser()) {
|
||||
sp.getString(if (event.isDm()) R.string.notice_direct_room_join_by_you else R.string.notice_room_join_by_you)
|
||||
else
|
||||
} else {
|
||||
sp.getString(if (event.isDm()) R.string.notice_direct_room_join else R.string.notice_room_join,
|
||||
senderDisplayName)
|
||||
}
|
||||
}
|
||||
Membership.LEAVE ->
|
||||
// 2 cases here: this member may have left voluntarily or they may have been "left" by someone else ie. kicked
|
||||
|
@ -559,18 +568,20 @@ class NoticeEventFormatter @Inject constructor(private val activeSessionDataSour
|
|||
}
|
||||
else ->
|
||||
eventContent.safeReason?.let { reason ->
|
||||
if (event.isSentByCurrentUser())
|
||||
if (event.isSentByCurrentUser()) {
|
||||
sp.getString(if (event.isDm()) R.string.notice_direct_room_leave_with_reason_by_you else R.string.notice_room_leave_with_reason_by_you,
|
||||
reason)
|
||||
else
|
||||
} else {
|
||||
sp.getString(if (event.isDm()) R.string.notice_direct_room_leave_with_reason else R.string.notice_room_leave_with_reason,
|
||||
senderDisplayName, reason)
|
||||
}
|
||||
} ?: run {
|
||||
if (event.isSentByCurrentUser())
|
||||
if (event.isSentByCurrentUser()) {
|
||||
sp.getString(if (event.isDm()) R.string.notice_direct_room_leave_by_you else R.string.notice_room_leave_by_you)
|
||||
else
|
||||
} else {
|
||||
sp.getString(if (event.isDm()) R.string.notice_direct_room_leave else R.string.notice_room_leave,
|
||||
senderDisplayName)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -637,11 +648,12 @@ class NoticeEventFormatter @Inject constructor(private val activeSessionDataSour
|
|||
val content = event.getClearContent().toModel<RoomJoinRulesContent>() ?: return null
|
||||
return when (content.joinRules) {
|
||||
RoomJoinRules.INVITE ->
|
||||
if (event.isSentByCurrentUser())
|
||||
if (event.isSentByCurrentUser()) {
|
||||
sp.getString(if (event.isDm()) R.string.direct_room_join_rules_invite_by_you else R.string.room_join_rules_invite_by_you)
|
||||
else
|
||||
} else {
|
||||
sp.getString(if (event.isDm()) R.string.direct_room_join_rules_invite else R.string.room_join_rules_invite,
|
||||
senderName)
|
||||
}
|
||||
RoomJoinRules.PUBLIC ->
|
||||
if (event.isSentByCurrentUser()) {
|
||||
sp.getString(R.string.room_join_rules_public_by_you)
|
||||
|
|
Loading…
Reference in New Issue