mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-10-23 02:12:25 +00:00
ios: move preparing and opening a group out of the "Open group?" alert
No change in behaviour: the next commit opens a directory result's group without the alert, through the same function. Run: 011-search-redesign, slice 3 (structural)
This commit is contained in:
1 parent
f49f9bff6a
commit
cf30d58579
1 file changed
+38
-19
@@ -1199,25 +1199,14 @@ private func showPrepareGroupAlert(
|
||||
secondTitle: connectOtherButton,
|
||||
onCancel: { cleanup?() },
|
||||
onConfirm: {
|
||||
Task {
|
||||
do {
|
||||
let chat = try await apiPrepareGroup(connLink: connectionLink, directLink: groupShortLinkInfo?.direct ?? true, groupShortLinkData: groupShortLinkData, verifiedDomain: verifiedDomain)
|
||||
await MainActor.run {
|
||||
if let relays = groupShortLinkInfo?.groupRelays, !relays.isEmpty,
|
||||
case let .group(gInfo, _) = chat.chatInfo {
|
||||
ChatModel.shared.channelRelayHostnames[gInfo.groupId] = relays
|
||||
}
|
||||
ChatModel.shared.addChat(Chat(chat))
|
||||
openKnownChat(chat.id, dismiss: dismiss, cleanup: cleanup)
|
||||
}
|
||||
} catch let error {
|
||||
logger.error("showPrepareGroupAlert apiPrepareGroup error: \(error.localizedDescription)")
|
||||
showAlert(NSLocalizedString(isChannel ? "Error opening channel" : "Error opening group", comment: "alert title"), message: responseError(error))
|
||||
await MainActor.run {
|
||||
cleanup?()
|
||||
}
|
||||
}
|
||||
}
|
||||
prepareAndOpenGroup(
|
||||
connectionLink: connectionLink,
|
||||
groupShortLinkInfo: groupShortLinkInfo,
|
||||
groupShortLinkData: groupShortLinkData,
|
||||
verifiedDomain: verifiedDomain,
|
||||
dismiss: dismiss,
|
||||
cleanup: cleanup
|
||||
)
|
||||
},
|
||||
onSecond: connectOtherLink.map { link in
|
||||
{ planAndConnect(link, theme: theme, dismiss: dismiss, cleanup: cleanup) }
|
||||
@@ -1225,6 +1214,36 @@ private func showPrepareGroupAlert(
|
||||
)
|
||||
}
|
||||
|
||||
private func prepareAndOpenGroup(
|
||||
connectionLink: CreatedConnLink,
|
||||
groupShortLinkInfo: GroupShortLinkInfo?,
|
||||
groupShortLinkData: GroupShortLinkData,
|
||||
verifiedDomain: SimplexDomain?,
|
||||
dismiss: Bool,
|
||||
cleanup: (() -> Void)?
|
||||
) {
|
||||
let isChannel = !(groupShortLinkInfo?.direct ?? true)
|
||||
Task {
|
||||
do {
|
||||
let chat = try await apiPrepareGroup(connLink: connectionLink, directLink: groupShortLinkInfo?.direct ?? true, groupShortLinkData: groupShortLinkData, verifiedDomain: verifiedDomain)
|
||||
await MainActor.run {
|
||||
if let relays = groupShortLinkInfo?.groupRelays, !relays.isEmpty,
|
||||
case let .group(gInfo, _) = chat.chatInfo {
|
||||
ChatModel.shared.channelRelayHostnames[gInfo.groupId] = relays
|
||||
}
|
||||
ChatModel.shared.addChat(Chat(chat))
|
||||
openKnownChat(chat.id, dismiss: dismiss, cleanup: cleanup)
|
||||
}
|
||||
} catch let error {
|
||||
logger.error("prepareAndOpenGroup apiPrepareGroup error: \(error.localizedDescription)")
|
||||
showAlert(NSLocalizedString(isChannel ? "Error opening channel" : "Error opening group", comment: "alert title"), message: responseError(error))
|
||||
await MainActor.run {
|
||||
cleanup?()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func showOpenKnownContactAlert(
|
||||
_ contact: Contact,
|
||||
theme: AppTheme,
|
||||
|
||||
Reference in new issue
Block a user