diff --git a/Telegram/Telegram-iOS/en.lproj/Localizable.strings b/Telegram/Telegram-iOS/en.lproj/Localizable.strings index 246e2ac80f..f7fc226e81 100644 --- a/Telegram/Telegram-iOS/en.lproj/Localizable.strings +++ b/Telegram/Telegram-iOS/en.lproj/Localizable.strings @@ -15846,6 +15846,7 @@ Error: %8$@"; "AuthConfirmation.Emoji.Title" = "Tap the emoji shown\non your other device"; "AuthConfirmation.Emoji.Description" = "Telegram wants to make sure it's really you."; +"AuthConfirmation.Emoji.DescriptionFirst" = "Telegram wants to make sure it's really you trying to log in to **%@**."; "Chat.TagPlaceholder" = "Tag"; diff --git a/submodules/TelegramUI/Components/AuthConfirmationScreen/Sources/AccountSwitchComponent.swift b/submodules/TelegramUI/Components/AuthConfirmationScreen/Sources/AccountSwitchComponent.swift index ab6dbf3193..9437dbfc42 100644 --- a/submodules/TelegramUI/Components/AuthConfirmationScreen/Sources/AccountSwitchComponent.swift +++ b/submodules/TelegramUI/Components/AuthConfirmationScreen/Sources/AccountSwitchComponent.swift @@ -82,6 +82,8 @@ final class AccountSwitchComponent: Component { func update(component: AccountSwitchComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { self.component = component + self.button.isUserInteractionEnabled = component.canSwitch + let size = CGSize(width: component.canSwitch ? 76.0 : 44.0, height: 44.0) let avatarSize = self.avatar.update( diff --git a/submodules/TelegramUI/Components/AuthConfirmationScreen/Sources/AuthConfirmationScreen.swift b/submodules/TelegramUI/Components/AuthConfirmationScreen/Sources/AuthConfirmationScreen.swift index 06ccee0120..0a6a210845 100644 --- a/submodules/TelegramUI/Components/AuthConfirmationScreen/Sources/AuthConfirmationScreen.swift +++ b/submodules/TelegramUI/Components/AuthConfirmationScreen/Sources/AuthConfirmationScreen.swift @@ -77,6 +77,8 @@ private final class AuthConfirmationSheetContent: CombinedComponent { var matchCodes: [String]? var selectedMatchCode: String? + var canSwitchAccount = false + init(context: AccountContext, requestSubject: MessageActionUrlSubject, subject: MessageActionUrlAuthResult, completion: @escaping (AccountContext, EnginePeer, AuthConfirmationScreen.Result) -> Void) { self.context = context self.requestSubject = requestSubject @@ -113,34 +115,42 @@ private final class AuthConfirmationSheetContent: CombinedComponent { } } - if case let .request(_, _, _, _, _, userIdHint) = self.subject, let userIdHint, userIdHint != context.account.peerId { + if case let .request(_, _, _, _, _, userIdHint) = self.subject { + let isTestEnvironment = context.account.testingEnvironment let _ = (activeAccountsAndPeers(context: self.context, includePrimary: true) |> take(1) |> deliverOnMainQueue).start(next: { [weak self] primary, other in guard let self else { return } + + var accountCount = 0 for (accountContext, peer, _) in other { - if peer.id == userIdHint { - self.forcedAccount = (accountContext, peer) - self.updated() - - accountContext.account.shouldBeServiceTaskMaster.set(.single(.now)) - let _ = (accountContext.engine.messages.requestMessageActionUrlAuth(subject: requestSubject) - |> deliverOnMainQueue).start(next: { [weak self] result in - guard let self, case .request = result else { - return - } - self.subject = result - if case let .request(_, _, _, flags, _, _) = result, !flags.contains(.showMatchCodesFirst) { - self.displayEmoji = false - self.matchCodes = nil - } - self.updated() - }) - break + if accountContext.account.testingEnvironment == isTestEnvironment { + accountCount += 1 + } + if let userIdHint, userIdHint != context.account.peerId { + if peer.id == userIdHint { + self.forcedAccount = (accountContext, peer) + + accountContext.account.shouldBeServiceTaskMaster.set(.single(.now)) + let _ = (accountContext.engine.messages.requestMessageActionUrlAuth(subject: requestSubject) + |> deliverOnMainQueue).start(next: { [weak self] result in + guard let self, case .request = result else { + return + } + self.subject = result + if case let .request(_, _, _, flags, _, _) = result, !flags.contains(.showMatchCodesFirst) { + self.displayEmoji = false + self.matchCodes = nil + } + self.updated() + }) + } } } + self.canSwitchAccount = accountCount > 0 + self.updated() }) } } @@ -217,6 +227,7 @@ private final class AuthConfirmationSheetContent: CombinedComponent { } let context = self.context + let isTestEnvironment = context.account.testingEnvironment let presentationData = self.context.sharedContext.currentPresentationData.with { $0 } let items: Signal<[ContextMenuItem], NoError> = activeAccountsAndPeers(context: self.context, includePrimary: true) |> take(1) @@ -240,7 +251,7 @@ private final class AuthConfirmationSheetContent: CombinedComponent { } for (accountContext, peer, _) in other { - guard !existingIds.contains(peer.id) else { + guard !existingIds.contains(peer.id), accountContext.account.testingEnvironment == isTestEnvironment else { continue } items.append(.custom(AccountPeerContextItem(context: accountContext, account: accountContext.account, peer: peer, action: { [weak self] _, f in @@ -343,7 +354,7 @@ private final class AuthConfirmationSheetContent: CombinedComponent { context: state.forcedAccount?.0 ?? component.context, theme: environment.theme, peer: state.forcedAccount?.1 ?? peer, - canSwitch: true, + canSwitch: state.canSwitchAccount, isVisible: true, action: { [weak state] sourceView in state?.presentAccountSwitchMenu(sourceView: sourceView) @@ -413,9 +424,16 @@ private final class AuthConfirmationSheetContent: CombinedComponent { contentHeight += emojiTitle.size.height contentHeight += 16.0 + let emojiDescriptionString: String + if flags.contains(.showMatchCodesFirst) { + emojiDescriptionString = strings.AuthConfirmation_Emoji_DescriptionFirst(domain).string + } else { + emojiDescriptionString = strings.AuthConfirmation_Emoji_Description + } + let emojiDescription = emojiDescription.update( component: MultilineTextComponent( - text: .markdown(text: strings.AuthConfirmation_Emoji_Description, attributes: MarkdownAttributes(body: MarkdownAttributeSet(font: textFont, textColor: theme.actionSheet.primaryTextColor), bold: MarkdownAttributeSet(font: boldTextFont, textColor: theme.actionSheet.primaryTextColor), link: MarkdownAttributeSet(font: textFont, textColor: theme.actionSheet.primaryTextColor), linkAttribute: { _ in return nil })), + text: .markdown(text: emojiDescriptionString, attributes: MarkdownAttributes(body: MarkdownAttributeSet(font: textFont, textColor: theme.actionSheet.primaryTextColor), bold: MarkdownAttributeSet(font: boldTextFont, textColor: theme.actionSheet.primaryTextColor), link: MarkdownAttributeSet(font: textFont, textColor: theme.actionSheet.primaryTextColor), linkAttribute: { _ in return nil })), horizontalAlignment: .center, maximumNumberOfLines: 3, lineSpacing: 0.2 diff --git a/submodules/TelegramUI/Components/Chat/ChatTextInputPanelNode/Sources/ChatTextInputPanelNode.swift b/submodules/TelegramUI/Components/Chat/ChatTextInputPanelNode/Sources/ChatTextInputPanelNode.swift index ad3ab67515..124269c80a 100644 --- a/submodules/TelegramUI/Components/Chat/ChatTextInputPanelNode/Sources/ChatTextInputPanelNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatTextInputPanelNode/Sources/ChatTextInputPanelNode.swift @@ -4837,12 +4837,18 @@ public class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDeleg if let strongSelf = self { strongSelf.formatAttributesLink(strongSelf) } - }, - UIAction(title: self.strings?.TextFormat_Date ?? "Date", image: nil) { [weak self] (action) in + } + ]) + + if hasSpoilers { + children.append(UIAction(title: self.strings?.TextFormat_Date ?? "Date", image: nil) { [weak self] (action) in if let strongSelf = self { strongSelf.formatAttributesDate(strongSelf) } - }, + }) + } + + children.append(contentsOf: [ UIAction(title: self.strings?.TextFormat_Strikethrough ?? "Strikethrough", image: nil) { [weak self] (action) in if let strongSelf = self { strongSelf.formatAttributesStrikethrough(strongSelf)