diff --git a/apple/OmnivoreKit/Sources/App/Views/Profile/RecommendationGroupView.swift b/apple/OmnivoreKit/Sources/App/Views/Profile/RecommendationGroupView.swift index 7687229f1..6db65d0a9 100644 --- a/apple/OmnivoreKit/Sources/App/Views/Profile/RecommendationGroupView.swift +++ b/apple/OmnivoreKit/Sources/App/Views/Profile/RecommendationGroupView.swift @@ -22,10 +22,16 @@ import Views func leaveGroup(dataService: DataService) async -> Bool { isLeaving = true - try? await dataService.leaveGroup(groupID: recommendationGroup.id) + defer { + isLeaving = false + } - isLeaving = false - Snackbar.show(message: "You have left the group.") + do { + try await dataService.leaveGroup(groupID: recommendationGroup.id) + Snackbar.show(message: "You have left the group.") + } catch { + return false + } return true } } diff --git a/apple/OmnivoreKit/Sources/Services/DataService/Mutations/LeaveGroup.swift b/apple/OmnivoreKit/Sources/Services/DataService/Mutations/LeaveGroup.swift index b5686d87d..47c2c90b4 100644 --- a/apple/OmnivoreKit/Sources/Services/DataService/Mutations/LeaveGroup.swift +++ b/apple/OmnivoreKit/Sources/Services/DataService/Mutations/LeaveGroup.swift @@ -37,8 +37,13 @@ public extension DataService { } switch payload.data { - case .saved: - continuation.resume() + case let .saved(success): + if success { + continuation.resume() + } else { + continuation.resume(throwing: BasicError.message(messageText: "Unknown error")) + } + return case let .error(errorMessage: errorMessage): continuation.resume(throwing: BasicError.message(messageText: errorMessage)) }