mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Add start secret chat confirmation alert
This commit is contained in:
parent
e1171e80d3
commit
840b3cf22a
@ -5088,3 +5088,6 @@ Any member of this group will be able to see messages in the channel.";
|
|||||||
"ChatList.DeletedChats_any" = "Deleted %@ chats";
|
"ChatList.DeletedChats_any" = "Deleted %@ chats";
|
||||||
|
|
||||||
"Appearance.ColorThemeNight" = "COLOR THEME — AUTO-NIGHT MODE";
|
"Appearance.ColorThemeNight" = "COLOR THEME — AUTO-NIGHT MODE";
|
||||||
|
|
||||||
|
"UserInfo.StartSecretChatConfirmation" = "Are you sure you want to start a secret chat with\n%@?";
|
||||||
|
"UserInfo.StartSecretChatStart" = "Start";
|
||||||
|
@ -1361,7 +1361,8 @@ public func userInfoController(context: AccountContext, peerId: PeerId, mode: Pe
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
startSecretChatImpl = { [weak controller] in
|
startSecretChatImpl = { [weak controller] in
|
||||||
let _ = (context.account.postbox.transaction { transaction -> PeerId? in
|
let _ = (context.account.postbox.transaction { transaction -> (Peer?, PeerId?) in
|
||||||
|
let peer = transaction.getPeer(peerId)
|
||||||
let filteredPeerIds = Array(transaction.getAssociatedPeerIds(peerId)).filter { $0.namespace == Namespaces.Peer.SecretChat }
|
let filteredPeerIds = Array(transaction.getAssociatedPeerIds(peerId)).filter { $0.namespace == Namespaces.Peer.SecretChat }
|
||||||
var activeIndices: [ChatListIndex] = []
|
var activeIndices: [ChatListIndex] = []
|
||||||
for associatedId in filteredPeerIds {
|
for associatedId in filteredPeerIds {
|
||||||
@ -1378,20 +1379,22 @@ public func userInfoController(context: AccountContext, peerId: PeerId, mode: Pe
|
|||||||
}
|
}
|
||||||
activeIndices.sort()
|
activeIndices.sort()
|
||||||
if let index = activeIndices.last {
|
if let index = activeIndices.last {
|
||||||
return index.messageIndex.id.peerId
|
return (peer, index.messageIndex.id.peerId)
|
||||||
} else {
|
} else {
|
||||||
return nil
|
return (peer, nil)
|
||||||
}
|
}
|
||||||
} |> deliverOnMainQueue).start(next: { currentPeerId in
|
} |> deliverOnMainQueue).start(next: { peer, currentPeerId in
|
||||||
if let currentPeerId = currentPeerId {
|
if let currentPeerId = currentPeerId {
|
||||||
if let navigationController = (controller?.navigationController as? NavigationController) {
|
if let navigationController = (controller?.navigationController as? NavigationController) {
|
||||||
context.sharedContext.navigateToChatController(NavigateToChatControllerParams(navigationController: navigationController, context: context, chatLocation: .peer(currentPeerId)))
|
context.sharedContext.navigateToChatController(NavigateToChatControllerParams(navigationController: navigationController, context: context, chatLocation: .peer(currentPeerId)))
|
||||||
}
|
}
|
||||||
} else {
|
} else if let controller = controller {
|
||||||
|
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
||||||
|
let displayTitle = peer?.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder) ?? ""
|
||||||
|
controller.present(textAlertController(context: context, title: nil, text: presentationData.strings.UserInfo_StartSecretChatConfirmation(displayTitle).0, actions: [TextAlertAction(type: .genericAction, title: presentationData.strings.Common_Cancel, action: {}), TextAlertAction(type: .defaultAction, title: presentationData.strings.UserInfo_StartSecretChatStart, action: {
|
||||||
var createSignal = createSecretChat(account: context.account, peerId: peerId)
|
var createSignal = createSecretChat(account: context.account, peerId: peerId)
|
||||||
var cancelImpl: (() -> Void)?
|
var cancelImpl: (() -> Void)?
|
||||||
let progressSignal = Signal<Never, NoError> { subscriber in
|
let progressSignal = Signal<Never, NoError> { subscriber in
|
||||||
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
|
||||||
let controller = OverlayStatusController(theme: presentationData.theme, type: .loading(cancelled: {
|
let controller = OverlayStatusController(theme: presentationData.theme, type: .loading(cancelled: {
|
||||||
cancelImpl?()
|
cancelImpl?()
|
||||||
}))
|
}))
|
||||||
@ -1416,16 +1419,17 @@ public func userInfoController(context: AccountContext, peerId: PeerId, mode: Pe
|
|||||||
createSecretChatDisposable.set(nil)
|
createSecretChatDisposable.set(nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
createSecretChatDisposable.set((createSignal |> deliverOnMainQueue).start(next: { peerId in
|
createSecretChatDisposable.set((createSignal |> deliverOnMainQueue).start(next: { [weak controller] peerId in
|
||||||
if let navigationController = (controller?.navigationController as? NavigationController) {
|
if let navigationController = (controller?.navigationController as? NavigationController) {
|
||||||
context.sharedContext.navigateToChatController(NavigateToChatControllerParams(navigationController: navigationController, context: context, chatLocation: .peer(peerId)))
|
context.sharedContext.navigateToChatController(NavigateToChatControllerParams(navigationController: navigationController, context: context, chatLocation: .peer(peerId)))
|
||||||
}
|
}
|
||||||
}, error: { _ in
|
}, error: { [weak controller] _ in
|
||||||
if let controller = controller {
|
if let controller = controller {
|
||||||
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
||||||
controller.present(textAlertController(context: context, title: nil, text: presentationData.strings.Login_UnknownError, actions: [TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_OK, action: {})]), in: .window(.root))
|
controller.present(textAlertController(context: context, title: nil, text: presentationData.strings.Login_UnknownError, actions: [TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_OK, action: {})]), in: .window(.root))
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
|
})]), in: .window(.root))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user