diff --git a/Telegram/Telegram-iOS/en.lproj/Localizable.strings b/Telegram/Telegram-iOS/en.lproj/Localizable.strings index e02d55ccbb..00648a40d0 100644 --- a/Telegram/Telegram-iOS/en.lproj/Localizable.strings +++ b/Telegram/Telegram-iOS/en.lproj/Localizable.strings @@ -9752,3 +9752,5 @@ Sorry for the inconvenience."; "StoryList.TooltipStoriesSavedToProfile_1" = "Story archived"; "StoryList.TooltipStoriesSavedToProfile_any" = "%d stories archived."; + +"Premium.New" = "NEW"; diff --git a/submodules/PremiumUI/Sources/PremiumIntroScreen.swift b/submodules/PremiumUI/Sources/PremiumIntroScreen.swift index c9a85ce700..1af8884c30 100644 --- a/submodules/PremiumUI/Sources/PremiumIntroScreen.swift +++ b/submodules/PremiumUI/Sources/PremiumIntroScreen.swift @@ -1738,7 +1738,8 @@ private final class PremiumIntroScreenContentComponent: CombinedComponent { subtitle: perk.subtitle(strings: strings), subtitleColor: subtitleColor, arrowColor: arrowColor, - accentColor: accentColor + accentColor: accentColor, + badge: perk.identifier == "stories" ? strings.Premium_New : nil ) ) ), diff --git a/submodules/TelegramUI/Components/MediaEditorScreen/Sources/MediaEditorScreen.swift b/submodules/TelegramUI/Components/MediaEditorScreen/Sources/MediaEditorScreen.swift index 70f3e0cdbb..4daebc72e2 100644 --- a/submodules/TelegramUI/Components/MediaEditorScreen/Sources/MediaEditorScreen.swift +++ b/submodules/TelegramUI/Components/MediaEditorScreen/Sources/MediaEditorScreen.swift @@ -413,7 +413,7 @@ final class MediaEditorScreenComponent: Component { if let view = self.inputPanel.view as? MessageInputPanelComponent.View { self.nextTransitionUserData = TextFieldComponent.AnimationHint(kind: .textFocusChanged) if view.isActive { - view.deactivateInput() + view.deactivateInput(force: true) } else { self.endEditing(true) } @@ -743,6 +743,9 @@ final class MediaEditorScreenComponent: Component { guard let controller = environment.controller() as? MediaEditorScreen else { return } + guard controller.checkCaptionLimit() else { + return + } if controller.isEditingStory { controller.requestCompletion(animated: true) } else { @@ -1197,9 +1200,11 @@ final class MediaEditorScreenComponent: Component { self.deactivateInput() } case .text: - let text = self.getInputText() - if text.length > component.context.userLimits.maxStoryCaptionLength { - controller.presentCaptionLimitPremiumSuggestion(isPremium: self.state?.isPremium ?? false) + Queue.mainQueue().after(0.1) { + let text = self.getInputText() + if text.length > component.context.userLimits.maxStoryCaptionLength { + controller.presentCaptionLimitPremiumSuggestion(isPremium: self.state?.isPremium ?? false) + } } default: break @@ -3892,6 +3897,20 @@ public final class MediaEditorScreen: ViewController, UIDropInteractionDelegate }) } } + + fileprivate func checkCaptionLimit() -> Bool { + let caption = self.getCaption() + if caption.length > self.context.userLimits.maxStoryCaptionLength { + let _ = (self.context.engine.data.get(TelegramEngine.EngineData.Item.Peer.Peer(id: self.context.account.peerId)) + |> deliverOnMainQueue).start(next: { [weak self] peer in + if let self { + self.presentCaptionLimitPremiumSuggestion(isPremium: peer?.isPremium ?? false) + } + }) + return false + } + return true + } private var didComplete = false func requestCompletion(animated: Bool) { @@ -4346,11 +4365,17 @@ public final class MediaEditorScreen: ViewController, UIDropInteractionDelegate if let controller = controller as? TooltipScreen { controller.dismiss() } + if let controller = controller as? UndoOverlayController { + controller.dismiss() + } }) self.forEachController({ controller in if let controller = controller as? TooltipScreen { controller.dismiss() } + if let controller = controller as? UndoOverlayController { + controller.dismiss() + } if let controller = controller as? SaveProgressScreen { controller.dismiss() } diff --git a/submodules/TelegramUI/Components/MessageInputPanelComponent/Sources/MessageInputPanelComponent.swift b/submodules/TelegramUI/Components/MessageInputPanelComponent/Sources/MessageInputPanelComponent.swift index ca1b302095..0d5b05cea8 100644 --- a/submodules/TelegramUI/Components/MessageInputPanelComponent/Sources/MessageInputPanelComponent.swift +++ b/submodules/TelegramUI/Components/MessageInputPanelComponent/Sources/MessageInputPanelComponent.swift @@ -462,8 +462,8 @@ public final class MessageInputPanelComponent: Component { } } - public func deactivateInput() { - if self.canDeactivateInput() { + public func deactivateInput(force: Bool = false) { + if self.canDeactivateInput() || force { if let textFieldView = self.textField.view as? TextFieldComponent.View { textFieldView.deactivateInput() } diff --git a/submodules/TelegramUI/Components/TextFieldComponent/Sources/TextFieldComponent.swift b/submodules/TelegramUI/Components/TextFieldComponent/Sources/TextFieldComponent.swift index f2e3adc8af..dc81a1c4fb 100644 --- a/submodules/TelegramUI/Components/TextFieldComponent/Sources/TextFieldComponent.swift +++ b/submodules/TelegramUI/Components/TextFieldComponent/Sources/TextFieldComponent.swift @@ -300,6 +300,7 @@ public final class TextFieldComponent: Component { } } self.state?.updated(transition: Transition(animation: .curve(duration: 0.4, curve: .spring)).withUserData(AnimationHint(kind: .textChanged))) + component.paste(.text) return false }