mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-10-31 16:24:11 +00:00
Knock Polishing part 4 (#3779)
* added decline and block and inviter redesign * improved testing * improved testing * code improvement * code improvement * improved the code
This commit is contained in:
@@ -390,6 +390,10 @@
|
||||
"screen_join_room_cancel_knock_alert_confirmation" = "Yes, cancel";
|
||||
"screen_join_room_cancel_knock_alert_description" = "Are you sure that you want to cancel your request to join this room?";
|
||||
"screen_join_room_cancel_knock_alert_title" = "Cancel request to join";
|
||||
"screen_join_room_decline_and_block_alert_confirmation" = "Yes, decline & block";
|
||||
"screen_join_room_decline_and_block_alert_message" = "Are you sure you want to decline the invite to join this room? This will also prevent %1$@ from contacting you or inviting you to rooms.";
|
||||
"screen_join_room_decline_and_block_alert_title" = "Decline invite & block";
|
||||
"screen_join_room_decline_and_block_button_title" = "Decline and block";
|
||||
"screen_join_room_knock_message_description" = "Message (optional)";
|
||||
"screen_join_room_knock_sent_description" = "You will receive an invite to join the room if your request is accepted.";
|
||||
"screen_join_room_knock_sent_title" = "Request to join sent";
|
||||
|
||||
@@ -390,6 +390,10 @@
|
||||
"screen_join_room_cancel_knock_alert_confirmation" = "Yes, cancel";
|
||||
"screen_join_room_cancel_knock_alert_description" = "Are you sure that you want to cancel your request to join this room?";
|
||||
"screen_join_room_cancel_knock_alert_title" = "Cancel request to join";
|
||||
"screen_join_room_decline_and_block_alert_confirmation" = "Yes, decline & block";
|
||||
"screen_join_room_decline_and_block_alert_message" = "Are you sure you want to decline the invite to join this room? This will also prevent %1$@ from contacting you or inviting you to rooms.";
|
||||
"screen_join_room_decline_and_block_alert_title" = "Decline invite & block";
|
||||
"screen_join_room_decline_and_block_button_title" = "Decline and block";
|
||||
"screen_join_room_knock_message_description" = "Message (optional)";
|
||||
"screen_join_room_knock_sent_description" = "You will receive an invite to join the room if your request is accepted.";
|
||||
"screen_join_room_knock_sent_title" = "Request to join sent";
|
||||
|
||||
@@ -1322,6 +1322,16 @@ internal enum L10n {
|
||||
internal static var screenJoinRoomCancelKnockAlertDescription: String { return L10n.tr("Localizable", "screen_join_room_cancel_knock_alert_description") }
|
||||
/// Cancel request to join
|
||||
internal static var screenJoinRoomCancelKnockAlertTitle: String { return L10n.tr("Localizable", "screen_join_room_cancel_knock_alert_title") }
|
||||
/// Yes, decline & block
|
||||
internal static var screenJoinRoomDeclineAndBlockAlertConfirmation: String { return L10n.tr("Localizable", "screen_join_room_decline_and_block_alert_confirmation") }
|
||||
/// Are you sure you want to decline the invite to join this room? This will also prevent %1$@ from contacting you or inviting you to rooms.
|
||||
internal static func screenJoinRoomDeclineAndBlockAlertMessage(_ p1: Any) -> String {
|
||||
return L10n.tr("Localizable", "screen_join_room_decline_and_block_alert_message", String(describing: p1))
|
||||
}
|
||||
/// Decline invite & block
|
||||
internal static var screenJoinRoomDeclineAndBlockAlertTitle: String { return L10n.tr("Localizable", "screen_join_room_decline_and_block_alert_title") }
|
||||
/// Decline and block
|
||||
internal static var screenJoinRoomDeclineAndBlockButtonTitle: String { return L10n.tr("Localizable", "screen_join_room_decline_and_block_button_title") }
|
||||
/// Joining the room failed.
|
||||
internal static var screenJoinRoomFailMessage: String { return L10n.tr("Localizable", "screen_join_room_fail_message") }
|
||||
/// This room is either invite-only or there might be restrictions to access at space level.
|
||||
|
||||
@@ -90,6 +90,7 @@ struct JoinRoomScreenViewStateBindings {
|
||||
|
||||
enum JoinRoomScreenAlertType {
|
||||
case declineInvite
|
||||
case declineInviteAndBlock
|
||||
case cancelKnock
|
||||
case loadingError
|
||||
}
|
||||
@@ -100,6 +101,7 @@ enum JoinRoomScreenViewAction {
|
||||
case join
|
||||
case acceptInvite
|
||||
case declineInvite
|
||||
case declineInviteAndBlock(userID: String)
|
||||
case forget
|
||||
case dismiss
|
||||
}
|
||||
|
||||
@@ -66,6 +66,8 @@ class JoinRoomScreenViewModel: JoinRoomScreenViewModelType, JoinRoomScreenViewMo
|
||||
showCancelKnockConfirmationAlert()
|
||||
case .dismiss:
|
||||
actionsSubject.send(.dismiss)
|
||||
case .declineInviteAndBlock(let userID):
|
||||
showDeclineAndBlockConfirmationAlert(userID: userID)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -302,7 +304,27 @@ class JoinRoomScreenViewModel: JoinRoomScreenViewModelType, JoinRoomScreenViewMo
|
||||
secondaryButton: .init(title: L10n.screenJoinRoomCancelKnockAlertConfirmation, role: .destructive) { Task { await self.cancelKnock() } })
|
||||
}
|
||||
|
||||
private func declineInvite() async {
|
||||
private func showDeclineAndBlockConfirmationAlert(userID: String) {
|
||||
state.bindings.alertInfo = .init(id: .declineInviteAndBlock,
|
||||
title: L10n.screenJoinRoomDeclineAndBlockAlertTitle,
|
||||
message: L10n.screenJoinRoomDeclineAndBlockAlertMessage(userID),
|
||||
primaryButton: .init(title: L10n.actionCancel, role: .cancel, action: nil),
|
||||
secondaryButton: .init(title: L10n.screenJoinRoomDeclineAndBlockAlertConfirmation, role: .destructive) { Task { await self.declineAndBlock(userID: userID) } })
|
||||
}
|
||||
|
||||
private func declineAndBlock(userID: String) async {
|
||||
guard await declineInvite() else {
|
||||
return
|
||||
}
|
||||
// The decline alert and the view are already dismissed at this point so we can dispatch this separately as a best effort
|
||||
// but only if the decline invite was succesfull
|
||||
Task {
|
||||
await clientProxy.ignoreUser(userID)
|
||||
}
|
||||
}
|
||||
|
||||
@discardableResult
|
||||
private func declineInvite() async -> Bool {
|
||||
defer {
|
||||
userIndicatorController.retractIndicatorWithId(roomID)
|
||||
}
|
||||
@@ -311,16 +333,18 @@ class JoinRoomScreenViewModel: JoinRoomScreenViewModelType, JoinRoomScreenViewMo
|
||||
|
||||
guard case let .invited(roomProxy) = room else {
|
||||
userIndicatorController.submitIndicator(.init(title: L10n.errorUnknown))
|
||||
return
|
||||
return false
|
||||
}
|
||||
|
||||
let result = await roomProxy.rejectInvitation()
|
||||
|
||||
if case .failure = result {
|
||||
userIndicatorController.submitIndicator(.init(title: L10n.errorUnknown))
|
||||
} else {
|
||||
actionsSubject.send(.dismiss)
|
||||
return false
|
||||
}
|
||||
|
||||
actionsSubject.send(.dismiss)
|
||||
return true
|
||||
}
|
||||
|
||||
private func cancelKnock() async {
|
||||
|
||||
@@ -18,9 +18,16 @@ struct JoinRoomScreen: View {
|
||||
private enum Focus {
|
||||
case knockMessage
|
||||
}
|
||||
|
||||
private var topPadding: CGFloat {
|
||||
if context.viewState.roomDetails?.inviter != nil {
|
||||
return 32
|
||||
}
|
||||
return context.viewState.mode == .knocked ? 151 : 44
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
FullscreenDialog(topPadding: context.viewState.mode == .knocked ? 151 : 35) {
|
||||
FullscreenDialog(topPadding: topPadding) {
|
||||
if context.viewState.mode == .loading {
|
||||
EmptyView()
|
||||
} else {
|
||||
@@ -50,6 +57,14 @@ struct JoinRoomScreen: View {
|
||||
@ViewBuilder
|
||||
private var defaultView: some View {
|
||||
VStack(spacing: 16) {
|
||||
if let inviter = context.viewState.roomDetails?.inviter {
|
||||
RoomInviterLabel(inviter: inviter, mediaProvider: context.mediaProvider)
|
||||
.multilineTextAlignment(.center)
|
||||
.font(.compound.bodyMD)
|
||||
.foregroundStyle(.compound.textSecondary)
|
||||
.padding(.bottom, 44)
|
||||
}
|
||||
|
||||
if let avatar = context.viewState.avatar {
|
||||
RoomAvatarImage(avatar: avatar,
|
||||
avatarSize: .room(on: .joinRoom),
|
||||
@@ -80,12 +95,6 @@ struct JoinRoomScreen: View {
|
||||
BadgeLabel(title: "\(memberCount)", icon: \.userProfile, isHighlighted: false)
|
||||
}
|
||||
|
||||
if let inviter = context.viewState.roomDetails?.inviter {
|
||||
RoomInviterLabel(inviter: inviter, mediaProvider: context.mediaProvider)
|
||||
.font(.compound.bodyMD)
|
||||
.foregroundStyle(.compound.textSecondary)
|
||||
}
|
||||
|
||||
if let topic = context.viewState.roomDetails?.topic {
|
||||
Text(topic)
|
||||
.font(.compound.bodyMD)
|
||||
@@ -178,8 +187,17 @@ struct JoinRoomScreen: View {
|
||||
bottomNoticeMessage(L10n.screenJoinRoomInviteRequiredMessage)
|
||||
case .invited:
|
||||
ViewThatFits {
|
||||
HStack(spacing: 8) { inviteButtons }
|
||||
VStack(spacing: 16) { inviteButtons }
|
||||
VStack(spacing: 24) {
|
||||
HStack(spacing: 16) {
|
||||
inviteButtons
|
||||
}
|
||||
declineAndBlockButton
|
||||
}
|
||||
|
||||
VStack(spacing: 16) {
|
||||
inviteButtons
|
||||
declineAndBlockButton
|
||||
}
|
||||
}
|
||||
case .banned(let sender, let reason):
|
||||
VStack(spacing: 24) {
|
||||
@@ -253,6 +271,19 @@ struct JoinRoomScreen: View {
|
||||
.buttonStyle(.compound(.primary))
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
var declineAndBlockButton: some View {
|
||||
if let inviter = context.viewState.roomDetails?.inviter {
|
||||
Button(role: .destructive) {
|
||||
context.send(viewAction: .declineInviteAndBlock(userID: inviter.id))
|
||||
} label: {
|
||||
Text(L10n.screenJoinRoomDeclineAndBlockButtonTitle)
|
||||
.padding(.vertical, 14)
|
||||
}
|
||||
.buttonStyle(.compound(.plain))
|
||||
}
|
||||
}
|
||||
|
||||
var joinButton: some View {
|
||||
Button(L10n.screenJoinRoomJoinAction) { context.send(viewAction: .join) }
|
||||
.buttonStyle(.compound(.super))
|
||||
|
||||
+2
-2
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:bef390e5063fc968023f3d7be436242923c42c22c5160ab91e9d9a941a726879
|
||||
size 185357
|
||||
oid sha256:df1aee7219d4bbfd8f017cbea15fecba95759c6585b2956607f7225551f634f9
|
||||
size 185269
|
||||
|
||||
+2
-2
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:0ddf683cd39f7ef235162eaf3ef56fd82385602fa8f9f3588238c73ea353238d
|
||||
size 186602
|
||||
oid sha256:8a0c0b480f1453610446966e63631f711c37e030e7249a2617b2a05ab5ac2d85
|
||||
size 186514
|
||||
|
||||
+2
-2
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:46d4db4ce035ccecd1f36555844bd7b36b9870b961a63e78ba8fd55524a97182
|
||||
size 168841
|
||||
oid sha256:82803c520760c01461b7e0421acafd15d891a170f8f0297261958b0591ddc7b1
|
||||
size 168753
|
||||
|
||||
+2
-2
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:ebc89ecca286720e20459176eb056e8cbdef378ec43650fe0ce3dca536d453f9
|
||||
size 177783
|
||||
oid sha256:ae7ef9f363ff4ff99f7845ebffc06849b507670f56be432e48ba2910d3e07cb8
|
||||
size 183459
|
||||
|
||||
+2
-2
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:4db229e703bfee04b734129935f840398262952ea982a28b2b439f5cfe17cd1f
|
||||
size 101098
|
||||
oid sha256:7179c2051979af73a92741a035af441763c51c7c8eaa08ab2c6703a30db5f761
|
||||
size 107060
|
||||
|
||||
+2
-2
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:9631828c623d72046f50e0adde6c5310b53314e62bf29c50341815592ae2d8a6
|
||||
size 176333
|
||||
oid sha256:a77b0ac39fa8a0f8c4e800b43b8363bb99b8dd2414415d5789819439bedee5e3
|
||||
size 176245
|
||||
|
||||
+2
-2
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:ea029779d25f9371956629e00cdbd28555d9f33c965099ae5bea3ccca474ee29
|
||||
size 188184
|
||||
oid sha256:2c89d14d409cf67179042b832b776dda5dc5aa490c997e16c1110de8b1c42507
|
||||
size 188027
|
||||
|
||||
+2
-2
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:730cc42657835ecc027ec83ec50f8ee2eb7715d7f24a17fa5c7208fa0245dfd9
|
||||
size 192443
|
||||
oid sha256:8c3f1b046cd605b1f8b3f0cf2ca18b658be334a0e6fbe487cdec127e7ebeaec3
|
||||
size 192355
|
||||
|
||||
+2
-2
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:dfc221af7a2bff00ab3107d7438cf0544bfe0b092d3c06174f067f54ac4beb78
|
||||
size 108616
|
||||
oid sha256:be5fc3e659a6a729eb954280bec6ad11488adfc89d55769d6d5ecde8c76541e8
|
||||
size 108595
|
||||
|
||||
+2
-2
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:1f071d51fa158d743a97add7023b148aaffc3024db9dabacdb73c00f8624d22d
|
||||
size 195453
|
||||
oid sha256:9e38494a7f7401913cf2d8eab1129f4f8e019ec078a3beb3149ed71a3f3a9862
|
||||
size 195365
|
||||
|
||||
+2
-2
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:8ce81edbe8762d0d67414c3d3673b1dee6638c91cd40f988edc1ce5f9d624964
|
||||
size 199410
|
||||
oid sha256:49d4316654203bf02fd59b6cd4a401e112d3385ac530cd8d5b30a00ad3a837ae
|
||||
size 199322
|
||||
|
||||
+2
-2
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:e2cc59fc58138ac6f3d81ab99ae2675b27757c5a7cc4d8ea7cd95f0bbbc701cd
|
||||
size 175215
|
||||
oid sha256:75814365e0671b555515a00496b61764a6f524bd17bc23c293dd5fcf56966927
|
||||
size 175127
|
||||
|
||||
+2
-2
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:1fe746b5db709ed299b4340566ee6a48cc20237dc3b9b2c2923c1de78903f7f4
|
||||
size 182572
|
||||
oid sha256:66ede7f9c86008ae9553711541f8aa44a2888de22dde7a2db46e2339ea6374fb
|
||||
size 186999
|
||||
|
||||
+2
-2
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:4ccbab1cae4ddf3e4db0fd0847b8c43e0acea5b0f8da45f17ca3221ad1cf6fb2
|
||||
size 105731
|
||||
oid sha256:3c113c3152efde1b3dd551f2d889d679e0fcbfc548f441cefbc1431206ef334c
|
||||
size 110563
|
||||
|
||||
+2
-2
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:8d2c3b773eb35ca1938e19eb413edefc154819ad296297d1db52d41bf4244a2b
|
||||
size 177403
|
||||
oid sha256:650bf015da1df6e94185102f4b4ffe0e47ed5bf38b7ceedd55c6f07d3adc787a
|
||||
size 177315
|
||||
|
||||
+2
-2
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:6cba375d9786e5f3f60729d90ea80e04512928b1d99c25df5a3e12797e56feab
|
||||
size 196127
|
||||
oid sha256:c5fce8e287c451894bb2f4d5c7deec5d637be8fb73489c7e4b18be6ffd7f70a9
|
||||
size 195977
|
||||
|
||||
+2
-2
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:87b5aaf1f670f1b424d88c531772596a4bec39b2a9fe9ecbb4f9db4be25cd705
|
||||
size 203750
|
||||
oid sha256:bf95a41a65ef4176425f827738a4de6e59f42035f8798db271116acbe098f2d8
|
||||
size 203662
|
||||
|
||||
+2
-2
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:296c8f2ad470843f69c3871e5ae0e2f064fbe3a29612a041319fe859d5f33f61
|
||||
size 121644
|
||||
oid sha256:949d7454a131322fcfae5ffd2472a95f3f32121f0b551a80fd6d2058ea415fb0
|
||||
size 121631
|
||||
|
||||
+2
-2
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:8ea4d0546bf12dbd0112d0d19caf1b31e4e11e76ce8a5a64a12345f6c9d083a2
|
||||
size 130402
|
||||
oid sha256:8a8c07fcf62abe2f6393b4f9d17a852faba5a4929ddfaf4e538502e255953e19
|
||||
size 130404
|
||||
|
||||
+2
-2
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:ba4bbbb005faa6b7375ad4cdf749df4bd0352e5ce80d480b13ff3ea6cf60a11d
|
||||
size 130267
|
||||
oid sha256:f1514365ab5f77e6eb724c86f2057f56b7fad08ef6cd407f8ee742ffcf602918
|
||||
size 130269
|
||||
|
||||
+2
-2
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:4f3d7c7aa395cd67be31942f8b80d764039f95ec7071b0796e0dee27e23e2aeb
|
||||
size 116366
|
||||
oid sha256:63c7254b3b6a89c549c16b798d8be2c5a28b5e6dacf61fd36a99227c68ce17f5
|
||||
size 116368
|
||||
|
||||
+2
-2
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:7c7599e77de7e4b067d4be8ed3475c6f13e2ebc890eba7da767ebb7be39d5839
|
||||
size 122089
|
||||
oid sha256:77b28865d2387c53f1683ab3a303010c3d7d744c5e3a011c38d55e7a2f2fa4e3
|
||||
size 126282
|
||||
|
||||
+2
-2
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:6c2f73672d7ab3c76f3613abce2da6888b26457401d30720e90932cd084569cf
|
||||
size 56394
|
||||
oid sha256:a2a6408a70b8d67791d156e8bc2dce8504a78a90e0e1408cc3c510845d2b0a9d
|
||||
size 61876
|
||||
|
||||
+2
-2
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:947f1bf8fdc8202333df2a4c11c77856de43bfec3e4c9286df332554f1ecc4f8
|
||||
size 118228
|
||||
oid sha256:e383eb4148924ea71e8ed8b218e2dcbf245a3de2c3c11e3740de01abbe22b26b
|
||||
size 118230
|
||||
|
||||
+2
-2
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:5b5261fe4972edfc4056168497f9fe4145cef7b108985d607c4347acd6aeef8b
|
||||
size 128093
|
||||
oid sha256:f77afea6a4985b153b5bee5884ffba6561aa11e42890dea03eda942d1a676f09
|
||||
size 128108
|
||||
|
||||
+2
-2
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:7c8a83efc1c0466a1a35246edf00eac29819d53d8a3175e135b59118588a14eb
|
||||
size 134920
|
||||
oid sha256:24406d04332b31ace30377955506c9ce5bbe194d21f380442ed427710aa9bfc7
|
||||
size 134922
|
||||
|
||||
+2
-2
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:7e6733dc72a1e261bfeeec1e037a7b38cbac6b131d939c65ee1a1168778a3375
|
||||
size 63367
|
||||
oid sha256:6bd7d29ba46b6201c65db1332d99496a74700af2c38800ed0fe94510cc509849
|
||||
size 63346
|
||||
|
||||
+2
-2
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:3d1751f36575511b3e495f86f40a246c7a906bb3f7f400a3c7cc964e9a4df7ee
|
||||
size 144788
|
||||
oid sha256:45b7399442cfd90c03bdb9833732c68adc64e700f130324e4c7d2c8eac6ff513
|
||||
size 144790
|
||||
|
||||
+2
-2
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:6bd53c22bda3f296f085a7862f0d9b562e2a5d2ba95daed4d01bec5511a9dd53
|
||||
size 148710
|
||||
oid sha256:b96ef931b4fef1d6dac15281bab3e92e78905ce7a03f8edebc5df55ad3ff0968
|
||||
size 148712
|
||||
|
||||
+2
-2
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:c6ef69abb4af5cd05c98801bf75d16f113c9de2b075a37195c1e1dd81d18ec16
|
||||
size 124936
|
||||
oid sha256:7db8c62c001ee8edee51ed54bdf0b858d30226a042c9bcb4908e050d6c826038
|
||||
size 124938
|
||||
|
||||
+2
-2
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:8a93efd02d0b494fd2f12b28a0ca032e0e454c05470180afabf7188482d91254
|
||||
size 129056
|
||||
oid sha256:0a9ecdd89f2942be9e73b2e19e6537bf54a7401e586e909e99421d47b20f8f33
|
||||
size 136513
|
||||
|
||||
+2
-2
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:0be9443668ec9caf1d88f1cdbabd05e2dd4eb156a2b3b58719d136912888bfc3
|
||||
size 63892
|
||||
oid sha256:81f85a54ef59dcbbd79c2108c1c243b175d69c4fd00838e79c2c6ed83a518a63
|
||||
size 70951
|
||||
|
||||
+2
-2
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:271c66b0fc2805da5afdf54cec271ef9a9cf269f7e2ba792090908007b19acb8
|
||||
size 120239
|
||||
oid sha256:e5aa8b3cce4b1fca0638666a18715691ab8058627927781b1a16d344a1fda101
|
||||
size 120241
|
||||
|
||||
+2
-2
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:83bb5f7f5eb52dec7256c42d97623638f866fe885b576f7fcdebdf881f972071
|
||||
size 134322
|
||||
oid sha256:35627cbe62d46f9fdb7cc31557ea0769b8a522ff791fc53e1e9fba0bac8f92bd
|
||||
size 134336
|
||||
|
||||
+2
-2
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:d6458f0d09edc8692ab962a81a0b8b56b189fa2336381fcf0244d810f0f37260
|
||||
size 150232
|
||||
oid sha256:4b8536c2a080adb622503acba2c432e19cf7e4f8d2d6dbe7adfb54da906e5146
|
||||
size 150234
|
||||
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:c6dcfd41a3dd2b5e196844aec0d1e7902c260ad444daafcb6855267753793a29
|
||||
oid sha256:fbdb9b50c256c56aa2d37ba6758d44747904b670a56a90338ab313fb7dbded39
|
||||
size 82604
|
||||
|
||||
@@ -11,7 +11,15 @@ import XCTest
|
||||
|
||||
@MainActor
|
||||
class JoinRoomScreenViewModelTests: XCTestCase {
|
||||
private enum TestMode {
|
||||
case joined
|
||||
case knocked
|
||||
case invited
|
||||
case banned
|
||||
}
|
||||
|
||||
var viewModel: JoinRoomScreenViewModelProtocol!
|
||||
var clientProxy: ClientProxyMock!
|
||||
|
||||
var context: JoinRoomScreenViewModelType.Context {
|
||||
viewModel.context
|
||||
@@ -19,6 +27,7 @@ class JoinRoomScreenViewModelTests: XCTestCase {
|
||||
|
||||
override func tearDown() {
|
||||
viewModel = nil
|
||||
clientProxy = nil
|
||||
AppSettings.resetAllSettings()
|
||||
}
|
||||
|
||||
@@ -39,17 +48,22 @@ class JoinRoomScreenViewModelTests: XCTestCase {
|
||||
}
|
||||
|
||||
func testDeclineInviteInteraction() async throws {
|
||||
setupViewModel()
|
||||
setupViewModel(mode: .invited)
|
||||
|
||||
try await deferFulfillment(viewModel.context.$viewState) { $0.roomDetails != nil }.fulfill()
|
||||
|
||||
context.send(viewAction: .declineInvite)
|
||||
|
||||
XCTAssertEqual(viewModel.context.alertInfo?.id, .declineInvite)
|
||||
let deferred = deferFulfillment(viewModel.actionsPublisher) { action in
|
||||
action == .dismiss
|
||||
}
|
||||
context.alertInfo?.secondaryButton?.action?()
|
||||
try await deferred.fulfill()
|
||||
}
|
||||
|
||||
func testKnockedState() async throws {
|
||||
setupViewModel(knocked: true)
|
||||
setupViewModel(mode: .knocked)
|
||||
|
||||
try await deferFulfillment(viewModel.context.$viewState) { state in
|
||||
state.mode == .knocked
|
||||
@@ -57,7 +71,7 @@ class JoinRoomScreenViewModelTests: XCTestCase {
|
||||
}
|
||||
|
||||
func testCancelKnock() async throws {
|
||||
setupViewModel(knocked: true)
|
||||
setupViewModel(mode: .knocked)
|
||||
|
||||
try await deferFulfillment(viewModel.context.$viewState) { state in
|
||||
state.mode == .knocked
|
||||
@@ -73,14 +87,51 @@ class JoinRoomScreenViewModelTests: XCTestCase {
|
||||
try await deferred.fulfill()
|
||||
}
|
||||
|
||||
private func setupViewModel(throwing: Bool = false, knocked: Bool = false) {
|
||||
func testDeclineAndBlockInviteInteraction() async throws {
|
||||
setupViewModel(mode: .invited)
|
||||
let expectation = expectation(description: "Wait for the user to be ignored")
|
||||
clientProxy.ignoreUserClosure = { userID in
|
||||
defer { expectation.fulfill() }
|
||||
XCTAssertEqual(userID, "@test:matrix.org")
|
||||
return .success(())
|
||||
}
|
||||
|
||||
try await deferFulfillment(viewModel.context.$viewState) { $0.roomDetails != nil }.fulfill()
|
||||
|
||||
context.send(viewAction: .declineInviteAndBlock(userID: "@test:matrix.org"))
|
||||
|
||||
XCTAssertEqual(viewModel.context.alertInfo?.id, .declineInviteAndBlock)
|
||||
|
||||
let deferred = deferFulfillment(viewModel.actionsPublisher) { action in
|
||||
action == .dismiss
|
||||
}
|
||||
context.alertInfo?.secondaryButton?.action?()
|
||||
try await deferred.fulfill()
|
||||
|
||||
await fulfillment(of: [expectation], timeout: 10)
|
||||
}
|
||||
|
||||
func testForgetRoom() async throws {
|
||||
setupViewModel(mode: .banned)
|
||||
|
||||
try await deferFulfillment(viewModel.context.$viewState) { $0.roomDetails != nil }.fulfill()
|
||||
|
||||
let deferred = deferFulfillment(viewModel.actionsPublisher) { action in
|
||||
action == .dismiss
|
||||
}
|
||||
context.send(viewAction: .forget)
|
||||
try await deferred.fulfill()
|
||||
}
|
||||
|
||||
private func setupViewModel(throwing: Bool = false, mode: TestMode = .joined) {
|
||||
ServiceLocator.shared.settings.knockingEnabled = true
|
||||
|
||||
let clientProxy = ClientProxyMock(.init())
|
||||
clientProxy = ClientProxyMock(.init())
|
||||
|
||||
clientProxy.joinRoomViaReturnValue = throwing ? .failure(.sdkError(ClientProxyMockError.generic)) : .success(())
|
||||
|
||||
if knocked {
|
||||
switch mode {
|
||||
case .knocked:
|
||||
clientProxy.roomPreviewForIdentifierViaReturnValue = .success(RoomPreviewProxyMock.knocked)
|
||||
|
||||
clientProxy.roomForIdentifierClosure = { _ in
|
||||
@@ -89,8 +140,22 @@ class JoinRoomScreenViewModelTests: XCTestCase {
|
||||
roomProxy.cancelKnockUnderlyingReturnValue = .success(())
|
||||
return .knocked(roomProxy)
|
||||
}
|
||||
} else {
|
||||
case .joined:
|
||||
clientProxy.roomPreviewForIdentifierViaReturnValue = .success(RoomPreviewProxyMock.joinable)
|
||||
case .invited:
|
||||
clientProxy.roomPreviewForIdentifierViaReturnValue = .success(RoomPreviewProxyMock.invited())
|
||||
clientProxy.roomForIdentifierClosure = { _ in
|
||||
let roomProxy = InvitedRoomProxyMock(.init())
|
||||
roomProxy.rejectInvitationReturnValue = .success(())
|
||||
return .invited(roomProxy)
|
||||
}
|
||||
case .banned:
|
||||
clientProxy.roomPreviewForIdentifierViaReturnValue = .success(RoomPreviewProxyMock.banned)
|
||||
clientProxy.roomForIdentifierClosure = { _ in
|
||||
let roomProxy = BannedRoomProxyMock(.init())
|
||||
roomProxy.forgetRoomReturnValue = .success(())
|
||||
return .banned(roomProxy)
|
||||
}
|
||||
}
|
||||
|
||||
viewModel = JoinRoomScreenViewModel(roomID: "1",
|
||||
|
||||
Reference in New Issue
Block a user