mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2024-12-17 17:20:21 +01:00
mobile: show errors when joining group (#861)
* mobile: show errors when joining group * correct titles Co-authored-by: JRoberts <8711996+jr-simplex@users.noreply.github.com> * improvements Co-authored-by: JRoberts <8711996+jr-simplex@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
ce91dcde7f
commit
cc0a74fae4
@@ -579,19 +579,20 @@ func apiAddMember(groupId: Int64, contactId: Int64, memberRole: GroupMemberRole)
|
||||
throw r
|
||||
}
|
||||
|
||||
func joinGroup(_ groupId: Int64) async {
|
||||
do {
|
||||
let groupInfo = try await apiJoinGroup(groupId)
|
||||
DispatchQueue.main.async { ChatModel.shared.updateGroup(groupInfo) }
|
||||
} catch let error {
|
||||
logger.error("joinGroup error: \(responseError(error))")
|
||||
}
|
||||
enum JoinGroupResult {
|
||||
case joined(groupInfo: GroupInfo)
|
||||
case invitationRemoved
|
||||
case groupNotFound
|
||||
}
|
||||
|
||||
func apiJoinGroup(_ groupId: Int64) async throws -> GroupInfo {
|
||||
func apiJoinGroup(_ groupId: Int64) async throws -> JoinGroupResult {
|
||||
let r = await chatSendCmd(.apiJoinGroup(groupId: groupId))
|
||||
if case let .userAcceptedGroupSent(groupInfo) = r { return groupInfo }
|
||||
throw r
|
||||
switch r {
|
||||
case let .userAcceptedGroupSent(groupInfo): return .joined(groupInfo: groupInfo)
|
||||
case .chatCmdError(.errorAgent(.SMP(.AUTH))): return .invitationRemoved
|
||||
case .chatCmdError(.errorStore(.groupNotFound)): return .groupNotFound
|
||||
default: throw r
|
||||
}
|
||||
}
|
||||
|
||||
func apiRemoveMember(groupId: Int64, memberId: Int64) async throws -> GroupMember {
|
||||
|
||||
Reference in New Issue
Block a user