From 61741d7e6147b7fa6bcab00607f4dc8599bc0e95 Mon Sep 17 00:00:00 2001 From: Oleg Date: Tue, 12 Mar 2024 15:50:48 +0700 Subject: [PATCH] MOB-1773 - Fixed blocking of users in chat (#429) --- .../project.pbxproj | 34 +++++++++---------- .../xcshareddata/swiftpm/Package.resolved | 7 ++-- .../ChatsList/ChatListViewModel.swift | 5 +-- .../Requests/ChatRequestsListViewModel.swift | 5 +-- .../MessagingService/MessagingService.swift | 7 ++-- 5 files changed, 31 insertions(+), 27 deletions(-) diff --git a/unstoppable-ios-app/domains-manager-ios.xcodeproj/project.pbxproj b/unstoppable-ios-app/domains-manager-ios.xcodeproj/project.pbxproj index 53ea393b8..2a02b516c 100644 --- a/unstoppable-ios-app/domains-manager-ios.xcodeproj/project.pbxproj +++ b/unstoppable-ios-app/domains-manager-ios.xcodeproj/project.pbxproj @@ -471,6 +471,7 @@ C61B3E90283E708500500B6D /* EnterEmailVerificationCodeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C61B3E8A283E708500500B6D /* EnterEmailVerificationCodeViewController.swift */; }; C61B3E94283E708500500B6D /* EnterEmailVerificationCodeViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = C61B3E8B283E708500500B6D /* EnterEmailVerificationCodeViewController.xib */; }; C61B3E99283E70C100500B6D /* EnterEmailVerificationCodeToMintDomainsPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = C61B3E98283E70C100500B6D /* EnterEmailVerificationCodeToMintDomainsPresenter.swift */; }; + C61B6C742BA0052C007408FD /* Push in Frameworks */ = {isa = PBXBuildFile; productRef = C61B6C732BA0052C007408FD /* Push */; }; C61C333A2B90CE6600BD11F5 /* MessagingChatUserDisplayInfoImageLoader.swift in Sources */ = {isa = PBXBuildFile; fileRef = C61C33392B90CE6600BD11F5 /* MessagingChatUserDisplayInfoImageLoader.swift */; }; C61C333B2B90CE6600BD11F5 /* MessagingChatUserDisplayInfoImageLoader.swift in Sources */ = {isa = PBXBuildFile; fileRef = C61C33392B90CE6600BD11F5 /* MessagingChatUserDisplayInfoImageLoader.swift */; }; C61C50002820E39600D1110A /* PullUpSelectionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C61C4FFF2820E39600D1110A /* PullUpSelectionView.swift */; }; @@ -678,7 +679,6 @@ C64312A22B68BB2900BCA2A4 /* ConnectedAppsEmptyCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = C643129F2B68BB2900BCA2A4 /* ConnectedAppsEmptyCell.swift */; }; C64312A32B68BB2900BCA2A4 /* ConnectedAppsEmptyCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = C64312A02B68BB2900BCA2A4 /* ConnectedAppsEmptyCell.xib */; }; C64312A42B68BB2900BCA2A4 /* ConnectedAppsEmptyCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = C64312A02B68BB2900BCA2A4 /* ConnectedAppsEmptyCell.xib */; }; - C64457822B85EBEB00F236A4 /* Push in Frameworks */ = {isa = PBXBuildFile; productRef = C64457812B85EBEB00F236A4 /* Push */; }; C64513072808089400413C51 /* UserDefaults.swift in Sources */ = {isa = PBXBuildFile; fileRef = C64513062808089400413C51 /* UserDefaults.swift */; }; C645130C280808ED00413C51 /* Codable.swift in Sources */ = {isa = PBXBuildFile; fileRef = C645130B280808ED00413C51 /* Codable.swift */; }; C645131128095BA400413C51 /* ExistingUsersTutorialViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C645131028095BA400413C51 /* ExistingUsersTutorialViewController.swift */; }; @@ -3637,7 +3637,6 @@ 307B1D5A2603C8E0007B14C3 /* BigInt in Frameworks */, 290A60502950AA1600882109 /* WalletConnectPush in Frameworks */, C66811F52B47B1C600BDABB0 /* XMTP in Frameworks */, - C64457822B85EBEB00F236A4 /* Push in Frameworks */, 2917EDDD2A6F25AB004EAB31 /* Web3ContractABI in Frameworks */, C689C1732ADE484300AA0186 /* LaunchDarkly in Frameworks */, 290A604E2950AA1600882109 /* WalletConnectPairing in Frameworks */, @@ -3647,6 +3646,7 @@ 30D89F5B26A9EB5500251C2D /* Bugsnag in Frameworks */, 290A60522950AA1600882109 /* WalletConnectRouter in Frameworks */, 30B6583926A9E75E004F707F /* Stripe in Frameworks */, + C61B6C742BA0052C007408FD /* Push in Frameworks */, 2917EDDB2A6F25AB004EAB31 /* Boilertalk-Web3 in Frameworks */, C652446A2AF8A7A400673CC0 /* WalletConnectNotify in Frameworks */, 290A60542950AA1600882109 /* WalletConnectVerify in Frameworks */, @@ -7682,7 +7682,7 @@ C65244692AF8A7A400673CC0 /* WalletConnectNotify */, C607A5CC2B3288900088ECF3 /* Amplitude */, C66811F42B47B1C600BDABB0 /* XMTP */, - C64457812B85EBEB00F236A4 /* Push */, + C61B6C732BA0052C007408FD /* Push */, ); productName = "domains-manager-ios"; productReference = 3064867D2527253700388026 /* domains-manager-ios.app */; @@ -7820,7 +7820,7 @@ C689C1712ADE47AF00AA0186 /* XCRemoteSwiftPackageReference "ios-client-sdk" */, C607A5CB2B3288800088ECF3 /* XCRemoteSwiftPackageReference "Amplitude-iOS" */, C66811F02B47B0F500BDABB0 /* XCRemoteSwiftPackageReference "xmtp-ios" */, - C64457802B85EBD300F236A4 /* XCRemoteSwiftPackageReference "push-swift-sdk" */, + C61B6C722BA004F2007408FD /* XCRemoteSwiftPackageReference "push-swift-sdk" */, ); productRefGroup = 3064867E2527253700388026 /* Products */; projectDirPath = ""; @@ -11004,6 +11004,14 @@ kind = branch; }; }; + C61B6C722BA004F2007408FD /* XCRemoteSwiftPackageReference "push-swift-sdk" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/ethereum-push-notification-service/push-swift-sdk"; + requirement = { + kind = revision; + revision = 45113991bb3eb6e7ab54556918a8aa523da85ce8; + }; + }; C61ECD842A25AB4200E97D70 /* XCRemoteSwiftPackageReference "socket" */ = { isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/socketio/socket.io-client-swift"; @@ -11028,14 +11036,6 @@ kind = branch; }; }; - C64457802B85EBD300F236A4 /* XCRemoteSwiftPackageReference "push-swift-sdk" */ = { - isa = XCRemoteSwiftPackageReference; - repositoryURL = "https://github.com/Oleg-Pecheneg/push-swift-sdk"; - requirement = { - kind = revision; - revision = 7aa3a1aeea89acd91dcbefcb0473a2a993a66334; - }; - }; C66811F02B47B0F500BDABB0 /* XCRemoteSwiftPackageReference "xmtp-ios" */ = { isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/xmtp/xmtp-ios"; @@ -11143,6 +11143,11 @@ package = 30CE604A26A9DED000E0D29B /* XCRemoteSwiftPackageReference "web3swift" */; productName = web3swift; }; + C61B6C732BA0052C007408FD /* Push */ = { + isa = XCSwiftPackageProductDependency; + package = C61B6C722BA004F2007408FD /* XCRemoteSwiftPackageReference "push-swift-sdk" */; + productName = Push; + }; C61ECD852A25AB4200E97D70 /* SocketIO */ = { isa = XCSwiftPackageProductDependency; package = C61ECD842A25AB4200E97D70 /* XCRemoteSwiftPackageReference "socket" */; @@ -11158,11 +11163,6 @@ package = C63812222993E009002590E7 /* XCRemoteSwiftPackageReference "Valet-ios" */; productName = Valet; }; - C64457812B85EBEB00F236A4 /* Push */ = { - isa = XCSwiftPackageProductDependency; - package = C64457802B85EBD300F236A4 /* XCRemoteSwiftPackageReference "push-swift-sdk" */; - productName = Push; - }; C65244692AF8A7A400673CC0 /* WalletConnectNotify */ = { isa = XCSwiftPackageProductDependency; package = 290A60462950AA1500882109 /* XCRemoteSwiftPackageReference "WalletConnectSwiftV2" */; diff --git a/unstoppable-ios-app/domains-manager-ios.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/unstoppable-ios-app/domains-manager-ios.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 4ae4e91c8..d91b4d881 100644 --- a/unstoppable-ios-app/domains-manager-ios.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/unstoppable-ios-app/domains-manager-ios.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -1,4 +1,5 @@ { + "originHash" : "7ef48ccc75c726c1506bc02084c676ce9561560c2e5a8b11a64a3392d2a42f0c", "pins" : [ { "identity" : "amplitude-ios", @@ -111,9 +112,9 @@ { "identity" : "push-swift-sdk", "kind" : "remoteSourceControl", - "location" : "https://github.com/Oleg-Pecheneg/push-swift-sdk", + "location" : "https://github.com/ethereum-push-notification-service/push-swift-sdk", "state" : { - "revision" : "7aa3a1aeea89acd91dcbefcb0473a2a993a66334" + "revision" : "45113991bb3eb6e7ab54556918a8aa523da85ce8" } }, { @@ -350,5 +351,5 @@ } } ], - "version" : 2 + "version" : 3 } diff --git a/unstoppable-ios-app/domains-manager-ios/Modules/Messaging/ChatsList/ChatListViewModel.swift b/unstoppable-ios-app/domains-manager-ios/Modules/Messaging/ChatsList/ChatListViewModel.swift index b14854e4b..3fd4daa45 100644 --- a/unstoppable-ios-app/domains-manager-ios/Modules/Messaging/ChatsList/ChatListViewModel.swift +++ b/unstoppable-ios-app/domains-manager-ios/Modules/Messaging/ChatsList/ChatListViewModel.swift @@ -568,8 +568,9 @@ private extension ChatListViewModel { } func fillSnapshotForUserChatsList() { - chatsRequests = chatsList.requestsOnly() - chatsListToShow = chatsList.confirmedOnly().unblockedOnly() + let unblockedChats = chatsList.unblockedOnly() + chatsRequests = unblockedChats.requestsOnly() + chatsListToShow = unblockedChats.confirmedOnly() } func fillSnapshotForUserCommunitiesList() { diff --git a/unstoppable-ios-app/domains-manager-ios/Modules/Messaging/ChatsList/Requests/ChatRequestsListViewModel.swift b/unstoppable-ios-app/domains-manager-ios/Modules/Messaging/ChatsList/Requests/ChatRequestsListViewModel.swift index d5856eab2..3acf831f0 100644 --- a/unstoppable-ios-app/domains-manager-ios/Modules/Messaging/ChatsList/Requests/ChatRequestsListViewModel.swift +++ b/unstoppable-ios-app/domains-manager-ios/Modules/Messaging/ChatsList/Requests/ChatRequestsListViewModel.swift @@ -59,12 +59,13 @@ extension ChatRequestsListViewModel { guard !selectedChats.isEmpty, case .chatRequests(let chats) = dataType else { return } + let chatsToBlock = Array(selectedChats) isEditing = false Task { isLoading = true do { - try await appContext.messagingService.block(chats: Array(selectedChats)) - if chats.count == selectedChats.count { + try await appContext.messagingService.block(chats: chatsToBlock) + if chats.count == chatsToBlock.count { router.chatTabNavPath.removeLast() } } catch { diff --git a/unstoppable-ios-app/domains-manager-ios/Services/MessagingService/MessagingService.swift b/unstoppable-ios-app/domains-manager-ios/Services/MessagingService/MessagingService.swift index c3add2fd2..4b0304fec 100644 --- a/unstoppable-ios-app/domains-manager-ios/Services/MessagingService/MessagingService.swift +++ b/unstoppable-ios-app/domains-manager-ios/Services/MessagingService/MessagingService.swift @@ -254,10 +254,11 @@ extension MessagingService: MessagingServiceProtocol { } try await apiService.block(chats: messagingChats, by: profile) + for chat in messagingChats { + try? await storageService.markAllMessagesIn(chat: chat, isRead: true) + } + if Constants.shouldHideBlockedUsersLocally { - for chat in messagingChats { - try? await storageService.markAllMessagesIn(chat: chat, isRead: true) - } notifyChatsChanged(wallet: profile.wallet, serviceIdentifier: serviceIdentifier) }