Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MOB-2103 - Do not auto-enable groups messaging profile for ULW #601

Merged
merged 1 commit into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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