Merge commit '974f1354453cb279885ffbd8a35b4a549a87c047'

This commit is contained in:
Ali
2023-10-29 20:30:34 +04:00
9 changed files with 46 additions and 23 deletions

View File

@@ -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()

View File

@@ -10,7 +10,7 @@ import TelegramPresentationData
import Markdown
import AlertUI
public func giveawayInfoController(context: AccountContext, updatedPresentationData: (initial: PresentationData, signal: Signal<PresentationData, NoError>)? = nil, message: EngineMessage, giveawayInfo: PremiumGiveawayInfo) -> ViewController? {
public func giveawayInfoController(context: AccountContext, updatedPresentationData: (initial: PresentationData, signal: Signal<PresentationData, NoError>)? = 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?()
})]

View File

@@ -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)

View File

@@ -105,7 +105,7 @@ final class AccountManagerImpl<Types: AccountManagerTypes> {
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()

View File

@@ -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

View File

@@ -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 {

View File

@@ -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))
}
})

View File

@@ -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() {

View File

@@ -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