Skip to content

Commit

Permalink
MOB-2103 - Do not auto-enable groups messaging profile for ULW (#601)
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleg-Pecheneg authored Jul 9, 2024
1 parent 211ebdc commit 6c9a41f
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,16 @@ final class MessagingService: MessagingServiceProtocol {
}

func createUserMessagingProfile(for wallet: WalletEntity) async throws -> MessagingChatUserProfileDisplayInfo {
.init(id: "1", wallet: wallet.address, serviceIdentifier: .xmtp)
await Task.sleep(seconds: 3)
return .init(id: "1", wallet: wallet.address, serviceIdentifier: .xmtp)
}

func isCommunitiesEnabled(for messagingProfile: MessagingChatUserProfileDisplayInfo) async -> Bool {
true
false
}

func createCommunityProfile(for messagingProfile: MessagingChatUserProfileDisplayInfo) async throws {

await Task.sleep(seconds: 3)
}

func setCurrentUser(_ userProfile: MessagingChatUserProfileDisplayInfo?) {
Expand Down Expand Up @@ -160,6 +161,7 @@ final class MessagingService: MessagingServiceProtocol {

func getUserMessagingProfile(for wallet: WalletEntity) async throws -> MessagingChatUserProfileDisplayInfo {
.init(id: "1", wallet: wallet.address, serviceIdentifier: .xmtp)
// throw NSError(domain: "3123", code: 2)
}

func getChatsListForProfile(_ profile: MessagingChatUserProfileDisplayInfo) async throws -> [MessagingChatDisplayInfo] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -363,8 +363,9 @@ private extension ChatListView {
subtitle: String.Constants.messagingCommunitiesListEnableSubtitle.localized(),
icon: .chatRequestsIcon,
actionButtonConfiguration: .init(buttonTitle: String.Constants.enable.localized(),
buttonIcon: Image(uiImage: appContext.authentificationService.biometricIcon ?? .init()),
buttonIcon: viewModel.isCreatingProfile ? nil : Image(uiImage: appContext.authentificationService.biometricIcon ?? .init()),
buttonStyle: .medium(.raisedPrimary),
isLoading: viewModel.isCreatingProfile,
buttonCallback: {
logButtonPressedAnalyticEvents(button: .createCommunityProfile)
viewModel.createCommunitiesProfileButtonPressed()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,10 @@ extension ChatListViewModel {
guard let selectedProfileWalletPair,
let profile = selectedProfileWalletPair.profile,
let view = appContext.coreAppCoordinator.topVC else { return }

do {
try await appContext.authentificationService.verifyWith(uiHandler: view,
purpose: .confirm)
isCreatingProfile = true
try await messagingService.createCommunityProfile(for: profile)
try await selectProfileWalletPair(.init(wallet: selectedProfileWalletPair.wallet,
profile: profile,
Expand All @@ -197,6 +197,7 @@ extension ChatListViewModel {
} catch {
self.error = error
}
isCreatingProfile = false
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ private extension ChatListEmptyStateView {
UDButtonView(text: actionButtonConfiguration.buttonTitle,
icon: actionButtonConfiguration.buttonIcon,
style: actionButtonConfiguration.buttonStyle,
isLoading: actionButtonConfiguration.isLoading,
callback: actionButtonConfiguration.buttonCallback)
}
}
Expand All @@ -55,8 +56,9 @@ private extension ChatListEmptyStateView {
extension ChatListEmptyStateView {
struct ActionButtonConfiguration {
let buttonTitle: String
let buttonIcon: Image
let buttonIcon: Image?
let buttonStyle: UDButtonStyle
var isLoading: Bool = false
let buttonCallback: MainActorCallback
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ extension MessagingService: MessagingServiceProtocol {

func createUserMessagingProfile(for wallet: WalletEntity) async throws -> MessagingChatUserProfileDisplayInfo {
let profile = try await createUserProfile(for: wallet, serviceIdentifier: defaultServiceIdentifier)
if Constants.isCommunitiesEnabled {
if wallet.udWallet.type != .mpc,
Constants.isCommunitiesEnabled {
_ = try? await createUserProfile(for: wallet, serviceIdentifier: communitiesServiceIdentifier)
}
return profile
Expand Down

0 comments on commit 6c9a41f

Please sign in to comment.