From 9e02ec560aab58b86604d463d2256bceb146fb5d Mon Sep 17 00:00:00 2001 From: Mike Renoir <> Date: Fri, 27 Oct 2023 17:56:12 +0400 Subject: [PATCH 1/3] syntax --- submodules/Postbox/Sources/StorageBox/StorageBox.swift | 2 +- .../Sources/AccountManager/AccountManagerImpl.swift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/submodules/Postbox/Sources/StorageBox/StorageBox.swift b/submodules/Postbox/Sources/StorageBox/StorageBox.swift index 67bc0ee380..ff73495535 100644 --- a/submodules/Postbox/Sources/StorageBox/StorageBox.swift +++ b/submodules/Postbox/Sources/StorageBox/StorageBox.swift @@ -190,7 +190,7 @@ public final class StorageBox { valueBox = SqliteValueBox(basePath: databasePath, queue: queue, isTemporary: false, isReadOnly: false, useCaches: isMainProcess, removeDatabaseOnError: isMainProcess, encryptionParameters: nil, upgradeProgress: { _ in }) } - guard let valueBox else { + guard let valueBox = valueBox else { postboxLog("Giving up on opening value box at \(basePath + "/db")") postboxLogSync() preconditionFailure() diff --git a/submodules/TelegramCore/Sources/AccountManager/AccountManagerImpl.swift b/submodules/TelegramCore/Sources/AccountManager/AccountManagerImpl.swift index 1c0ef6e96d..3b013823b0 100644 --- a/submodules/TelegramCore/Sources/AccountManager/AccountManagerImpl.swift +++ b/submodules/TelegramCore/Sources/AccountManager/AccountManagerImpl.swift @@ -105,7 +105,7 @@ final class AccountManagerImpl { Thread.sleep(forTimeInterval: 0.1 + 0.5 * Double(i)) } } - guard let valueBox else { + guard let valueBox = valueBox else { postboxLog("Giving up on opening value box at \(basePath + "/db")") postboxLogSync() preconditionFailure() From 32de3c0e5300dd6807f8c609426e0e1113b6ecf6 Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Sun, 29 Oct 2023 17:52:44 +0400 Subject: [PATCH 2/3] Various fixes --- .../Sources/MediaEditorVideoExport.swift | 8 ++++---- .../Sources/PeerNameColorScreen.swift | 6 +++++- submodules/WebUI/Sources/WebAppController.swift | 16 +++++++++++++++- submodules/WebUI/Sources/WebAppWebView.swift | 6 +++--- 4 files changed, 27 insertions(+), 9 deletions(-) diff --git a/submodules/TelegramUI/Components/MediaEditor/Sources/MediaEditorVideoExport.swift b/submodules/TelegramUI/Components/MediaEditor/Sources/MediaEditorVideoExport.swift index 86dc26ce32..91c821b902 100644 --- a/submodules/TelegramUI/Components/MediaEditor/Sources/MediaEditorVideoExport.swift +++ b/submodules/TelegramUI/Components/MediaEditor/Sources/MediaEditorVideoExport.swift @@ -387,12 +387,12 @@ public final class MediaEditorVideoExport { } switch self.subject { - case let .video(asset, _): + case let .video(asset, isStory): var additionalAsset: AVAsset? if let additionalPath = self.configuration.values.additionalVideoPath { additionalAsset = AVURLAsset(url: URL(fileURLWithPath: additionalPath)) } - self.setupWithAsset(asset, additionalAsset: additionalAsset) + self.setupWithAsset(asset, additionalAsset: additionalAsset, isStory: isStory) case let .image(image): self.setupWithImage(image) } @@ -405,7 +405,7 @@ public final class MediaEditorVideoExport { self.composer = MediaEditorComposer(postbox: self.postbox, values: self.configuration.values, dimensions: self.configuration.composerDimensions, outputDimensions: self.configuration.dimensions, textScale: self.textScale) } - private func setupWithAsset(_ asset: AVAsset, additionalAsset: AVAsset?) { + private func setupWithAsset(_ asset: AVAsset, additionalAsset: AVAsset?, isStory: Bool) { var inputAsset = asset var inputAudioMix: AVMutableAudioMix? @@ -476,7 +476,7 @@ public final class MediaEditorVideoExport { if let timeRange = self.configuration.timeRange { reader.timeRange = timeRange self.additionalReader?.timeRange = timeRange - } else if asset.duration.seconds > 60.0 { + } else if asset.duration.seconds > 60.0 && isStory { let trimmedRange = CMTimeRange(start: CMTime(seconds: 0.0, preferredTimescale: CMTimeScale(NSEC_PER_SEC)), end: CMTime(seconds: 60.0, preferredTimescale: CMTimeScale(NSEC_PER_SEC))) reader.timeRange = trimmedRange self.additionalReader?.timeRange = trimmedRange diff --git a/submodules/TelegramUI/Components/Settings/PeerNameColorScreen/Sources/PeerNameColorScreen.swift b/submodules/TelegramUI/Components/Settings/PeerNameColorScreen/Sources/PeerNameColorScreen.swift index f53d3776cd..5e7b0a62ba 100644 --- a/submodules/TelegramUI/Components/Settings/PeerNameColorScreen/Sources/PeerNameColorScreen.swift +++ b/submodules/TelegramUI/Components/Settings/PeerNameColorScreen/Sources/PeerNameColorScreen.swift @@ -534,7 +534,11 @@ public func PeerNameColorScreen( guard let controller else { return } - controller.present(c, in: .current) + if c is UndoOverlayController { + controller.present(c, in: .current) + } else { + controller.present(c, in: .window(.root)) + } } pushImpl = { [weak controller] c in guard let controller else { diff --git a/submodules/WebUI/Sources/WebAppController.swift b/submodules/WebUI/Sources/WebAppController.swift index 6bc6826fa0..52269bb863 100644 --- a/submodules/WebUI/Sources/WebAppController.swift +++ b/submodules/WebUI/Sources/WebAppController.swift @@ -235,7 +235,6 @@ public struct WebAppParameters { public func generateWebAppThemeParams(_ presentationTheme: PresentationTheme) -> [String: Any] { let backgroundColor = presentationTheme.list.plainBackgroundColor.rgb let secondaryBackgroundColor = presentationTheme.list.blocksBackgroundColor.rgb - return [ "bg_color": Int32(bitPattern: backgroundColor), "secondary_bg_color": Int32(bitPattern: secondaryBackgroundColor), @@ -329,6 +328,13 @@ public final class WebAppController: ViewController, AttachmentContainable { strongSelf.handleScriptMessage(delayedScriptMessage) } } + if #available(iOS 13.0, *) { + if self.presentationData.theme.overallDarkAppearance { + webView.overrideUserInterfaceStyle = .dark + } else { + webView.overrideUserInterfaceStyle = .unspecified + } + } self.webView = webView self.addSubnode(self.backgroundNode) @@ -1120,6 +1126,14 @@ public final class WebAppController: ViewController, AttachmentContainable { } self.updateHeaderBackgroundColor(transition: .immediate) self.sendThemeChangedEvent() + + if #available(iOS 13.0, *) { + if self.presentationData.theme.overallDarkAppearance { + self.webView?.overrideUserInterfaceStyle = .dark + } else { + self.webView?.overrideUserInterfaceStyle = .unspecified + } + } } private func sendThemeChangedEvent() { diff --git a/submodules/WebUI/Sources/WebAppWebView.swift b/submodules/WebUI/Sources/WebAppWebView.swift index 26a8eca621..34fa385c29 100644 --- a/submodules/WebUI/Sources/WebAppWebView.swift +++ b/submodules/WebUI/Sources/WebAppWebView.swift @@ -66,7 +66,7 @@ final class WebAppWebView: WKWebView { configuration.allowsInlineMediaPlayback = true configuration.allowsPictureInPictureMediaPlayback = false - if #available(iOSApplicationExtension 10.0, iOS 10.0, *) { + if #available(iOS 10.0, *) { configuration.mediaTypesRequiringUserActionForPlayback = .all } else { configuration.mediaPlaybackRequiresUserAction = true @@ -78,10 +78,10 @@ final class WebAppWebView: WKWebView { self.isOpaque = false self.backgroundColor = .clear - if #available(iOSApplicationExtension 9.0, iOS 9.0, *) { + if #available(iOS 9.0, *) { self.allowsLinkPreview = false } - if #available(iOSApplicationExtension 11.0, iOS 11.0, *) { + if #available(iOS 11.0, *) { self.scrollView.contentInsetAdjustmentBehavior = .never } self.interactiveTransitionGestureRecognizerTest = { point -> Bool in From 974f1354453cb279885ffbd8a35b4a549a87c047 Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Sun, 29 Oct 2023 18:43:32 +0400 Subject: [PATCH 3/3] Various fixes --- .../Sources/GiveawayInfoController.swift | 4 ++-- .../PremiumUI/Sources/PremiumLimitScreen.swift | 18 +++++++++--------- .../TelegramUI/Sources/ChatController.swift | 7 ++++++- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/submodules/PremiumUI/Sources/GiveawayInfoController.swift b/submodules/PremiumUI/Sources/GiveawayInfoController.swift index 7254a63fe7..7719ac3f2e 100644 --- a/submodules/PremiumUI/Sources/GiveawayInfoController.swift +++ b/submodules/PremiumUI/Sources/GiveawayInfoController.swift @@ -10,7 +10,7 @@ import TelegramPresentationData import Markdown import AlertUI -public func giveawayInfoController(context: AccountContext, updatedPresentationData: (initial: PresentationData, signal: Signal)? = nil, message: EngineMessage, giveawayInfo: PremiumGiveawayInfo) -> ViewController? { +public func giveawayInfoController(context: AccountContext, updatedPresentationData: (initial: PresentationData, signal: Signal)? = nil, message: EngineMessage, giveawayInfo: PremiumGiveawayInfo, openLink: @escaping (String) -> Void) -> ViewController? { guard let giveaway = message.media.first(where: { $0 is TelegramMediaGiveaway }) as? TelegramMediaGiveaway else { return nil } @@ -138,9 +138,9 @@ public func giveawayInfoController(context: AccountContext, updatedPresentationD result = "\n\n" + presentationData.strings.Chat_Giveaway_Info_DidntWin case let .won(slug): result = "\n\n" + presentationData.strings.Chat_Giveaway_Info_Won("🏆").string - let _ = slug actions = [TextAlertAction(type: .defaultAction, title: presentationData.strings.Chat_Giveaway_Info_ViewPrize, action: { dismissImpl?() + openLink(slug) }), TextAlertAction(type: .genericAction, title: presentationData.strings.Common_Cancel, action: { dismissImpl?() })] diff --git a/submodules/PremiumUI/Sources/PremiumLimitScreen.swift b/submodules/PremiumUI/Sources/PremiumLimitScreen.swift index 1fd9ad03ff..0ecbf43532 100644 --- a/submodules/PremiumUI/Sources/PremiumLimitScreen.swift +++ b/submodules/PremiumUI/Sources/PremiumLimitScreen.swift @@ -1176,18 +1176,18 @@ private final class LimitSheetContent: CombinedComponent { if let remaining { let storiesString = strings.ChannelBoost_StoriesPerDay(level + 1) let valueString = strings.ChannelBoost_MoreBoosts(remaining) - if level == 0 { - switch boostSubject { - case .stories: + switch boostSubject { + case .stories: + if level == 0 { titleText = strings.ChannelBoost_EnableStories string = strings.ChannelBoost_EnableStoriesText(valueString).string - case .nameColors: - titleText = strings.ChannelBoost_EnableColors - string = strings.ChannelBoost_EnableColorsText(valueString).string + } else { + titleText = strings.ChannelBoost_IncreaseLimit + string = strings.ChannelBoost_IncreaseLimitText(valueString, storiesString).string } - } else { - titleText = strings.ChannelBoost_IncreaseLimit - string = strings.ChannelBoost_IncreaseLimitText(valueString, storiesString).string + case .nameColors: + titleText = strings.ChannelBoost_EnableColors + string = strings.ChannelBoost_EnableColorsText(valueString).string } } else { let storiesString = strings.ChannelBoost_StoriesPerDay(level) diff --git a/submodules/TelegramUI/Sources/ChatController.swift b/submodules/TelegramUI/Sources/ChatController.swift index 4c453a7ef9..2915acc7c3 100644 --- a/submodules/TelegramUI/Sources/ChatController.swift +++ b/submodules/TelegramUI/Sources/ChatController.swift @@ -19179,7 +19179,12 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G guard let self, let message else { return } - if let controller = giveawayInfoController(context: self.context, updatedPresentationData: self.updatedPresentationData, message: message, giveawayInfo: giveawayInfo) { + if let controller = giveawayInfoController(context: self.context, updatedPresentationData: self.updatedPresentationData, message: message, giveawayInfo: giveawayInfo, openLink: { [weak self] slug in + guard let self else { + return + } + self.openResolved(result: .premiumGiftCode(slug: slug), sourceMessageId: messageId) + }) { self.present(controller, in: .window(.root)) } })