Skip to content

Commit d62c37a

Browse files
committed
Merge branch 'master' of gitlab.com:peter-iakovlev/telegram-ios
2 parents 7a89a58 + b51d1a2 commit d62c37a

File tree

26 files changed

+381
-216
lines changed

26 files changed

+381
-216
lines changed

Telegram/Telegram-iOS/en.lproj/Localizable.strings

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13805,6 +13805,13 @@ Sorry for the inconvenience.";
1380513805
"Notification.StarsGift.TransferToChannel" = "%1$@ transferred a unique collectible to %2$@";
1380613806
"Notification.StarsGift.TransferToChannelYou" = "You transferred a unique collectible to %@";
1380713807

13808+
"Gift.Convert.Success.ChannelText" = "**%1$@** were sent to channel's balance.";
13809+
"Gift.Convert.Success.ChannelText.Stars_1" = "%@ Star";
13810+
"Gift.Convert.Success.ChannelText.Stars_any" = "%@ Stars";
13811+
13812+
"Stars.Transfer.Terms" = "By purchasing you agree to the [Terms of Service]().";
13813+
"Stars.Transfer.Terms_URL" = "https://telegram.org/tos/stars";
13814+
1380813815
"AvatarEditor.PremiumNeeded.Background" = "Subscribe to Telegram Premium to choose this background.";
1380913816
"AvatarEditor.PremiumNeeded.Emoji" = "Subscribe to Telegram Premium to choose this emoji.";
1381013817
"AvatarEditor.PremiumNeeded.Sticker" = "Subscribe to Telegram Premium to choose this sticker.";
@@ -13981,3 +13988,7 @@ Sorry for the inconvenience.";
1398113988

1398213989
"Privacy.Review.Invite.Title" = "Invitation Settings";
1398313990
"Privacy.Review.Invite.Text" = "You've restricted who can message you, but anyone can still invite you to groups and channels. Would you like to review these settings?";
13991+
13992+
"Conversation.VideoTimeLinkCopied" = "Link with start time at %@ copied to clipboard.";
13993+
"Share.VideoStartAt" = "Start at %@";
13994+
"SendStarReactions.SubtitleFrom" = "from %@";

build_number_offset

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2510
1+
2515

submodules/AccountContext/Sources/OpenChatMessage.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ public final class OpenChatMessageParams {
4848
public let gallerySource: GalleryControllerItemSource?
4949
public let centralItemUpdated: ((MessageId) -> Void)?
5050
public let getSourceRect: (() -> CGRect?)?
51+
public let blockInteraction: Promise<Bool>
5152

5253
public init(
5354
context: AccountContext,
@@ -109,5 +110,6 @@ public final class OpenChatMessageParams {
109110
self.gallerySource = gallerySource
110111
self.centralItemUpdated = centralItemUpdated
111112
self.getSourceRect = getSourceRect
113+
self.blockInteraction = Promise()
112114
}
113115
}

submodules/ChatListUI/Sources/ChatListSearchListPaneNode.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3566,12 +3566,24 @@ final class ChatListSearchListPaneNode: ASDisplayNode, ChatListSearchPaneNode {
35663566
}
35673567
})
35683568
}, openStories: { peerId, avatarNode in
3569+
guard let strongSelf = self else {
3570+
return
3571+
}
35693572
strongSelf.interaction.openStories?(peerId, avatarNode)
35703573
}, openPublicPosts: {
3574+
guard let strongSelf = self else {
3575+
return
3576+
}
35713577
strongSelf.interaction.switchToFilter(.publicPosts)
35723578
}, openMessagesFilter: { sourceNode in
3579+
guard let strongSelf = self else {
3580+
return
3581+
}
35733582
strongSelf.openMessagesFilter(sourceNode: sourceNode)
35743583
}, switchMessagesFilter: { filter in
3584+
guard let strongSelf = self else {
3585+
return
3586+
}
35753587
strongSelf.searchScopePromise.set(.everywhere)
35763588
})
35773589
strongSelf.currentEntries = newEntries

submodules/DebugSettingsUI/Sources/DebugController.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ private enum DebugControllerEntry: ItemListNodeEntry {
100100
case enableReactionOverrides(Bool)
101101
case storiesExperiment(Bool)
102102
case storiesJpegExperiment(Bool)
103-
case playlistPlayback(Bool)
103+
case conferenceDebug(Bool)
104104
case enableQuickReactionSwitch(Bool)
105105
case disableReloginTokens(Bool)
106106
case liveStreamV2(Bool)
@@ -133,7 +133,7 @@ private enum DebugControllerEntry: ItemListNodeEntry {
133133
return DebugControllerSection.web.rawValue
134134
case .keepChatNavigationStack, .skipReadHistory, .dustEffect, .crashOnSlowQueries, .crashOnMemoryPressure:
135135
return DebugControllerSection.experiments.rawValue
136-
case .clearTips, .resetNotifications, .crash, .fillLocalSavedMessageCache, .resetDatabase, .resetDatabaseAndCache, .resetHoles, .resetTagHoles, .reindexUnread, .resetCacheIndex, .reindexCache, .resetBiometricsData, .optimizeDatabase, .photoPreview, .knockoutWallpaper, .storiesExperiment, .storiesJpegExperiment, .playlistPlayback, .enableQuickReactionSwitch, .experimentalCompatibility, .enableDebugDataDisplay, .rippleEffect, .browserExperiment, .localTranscription, .enableReactionOverrides, .restorePurchases, .disableReloginTokens, .liveStreamV2, .experimentalCallMute, .playerV2, .devRequests, .fakeAds, .enableLocalTranslation:
136+
case .clearTips, .resetNotifications, .crash, .fillLocalSavedMessageCache, .resetDatabase, .resetDatabaseAndCache, .resetHoles, .resetTagHoles, .reindexUnread, .resetCacheIndex, .reindexCache, .resetBiometricsData, .optimizeDatabase, .photoPreview, .knockoutWallpaper, .storiesExperiment, .storiesJpegExperiment, .conferenceDebug, .enableQuickReactionSwitch, .experimentalCompatibility, .enableDebugDataDisplay, .rippleEffect, .browserExperiment, .localTranscription, .enableReactionOverrides, .restorePurchases, .disableReloginTokens, .liveStreamV2, .experimentalCallMute, .playerV2, .devRequests, .fakeAds, .enableLocalTranslation:
137137
return DebugControllerSection.experiments.rawValue
138138
case .logTranslationRecognition, .resetTranslationStates:
139139
return DebugControllerSection.translation.rawValue
@@ -242,7 +242,7 @@ private enum DebugControllerEntry: ItemListNodeEntry {
242242
return 47
243243
case .disableReloginTokens:
244244
return 48
245-
case .playlistPlayback:
245+
case .conferenceDebug:
246246
return 49
247247
case .enableQuickReactionSwitch:
248248
return 50
@@ -1308,12 +1308,12 @@ private enum DebugControllerEntry: ItemListNodeEntry {
13081308
})
13091309
}).start()
13101310
})
1311-
case let .playlistPlayback(value):
1312-
return ItemListSwitchItem(presentationData: presentationData, title: "Playlist Playback", value: value, sectionId: self.section, style: .blocks, updated: { value in
1311+
case let .conferenceDebug(value):
1312+
return ItemListSwitchItem(presentationData: presentationData, title: "Conference Debug", value: value, sectionId: self.section, style: .blocks, updated: { value in
13131313
let _ = arguments.sharedContext.accountManager.transaction ({ transaction in
13141314
transaction.updateSharedData(ApplicationSpecificSharedDataKeys.experimentalUISettings, { settings in
13151315
var settings = settings?.get(ExperimentalUISettings.self) ?? ExperimentalUISettings.defaultSettings
1316-
settings.playlistPlayback = value
1316+
settings.conferenceDebug = value
13171317
return PreferencesEntry(settings)
13181318
})
13191319
}).start()
@@ -1540,7 +1540,7 @@ private func debugControllerEntries(sharedContext: SharedAccountContext, present
15401540
entries.append(.storiesJpegExperiment(experimentalSettings.storiesJpegExperiment))
15411541
entries.append(.disableReloginTokens(experimentalSettings.disableReloginTokens))
15421542
}
1543-
entries.append(.playlistPlayback(experimentalSettings.playlistPlayback))
1543+
entries.append(.conferenceDebug(experimentalSettings.conferenceDebug))
15441544
entries.append(.enableQuickReactionSwitch(!experimentalSettings.disableQuickReaction))
15451545
entries.append(.liveStreamV2(experimentalSettings.liveStreamV2))
15461546
entries.append(.experimentalCallMute(experimentalSettings.experimentalCallMute))

submodules/GalleryUI/Sources/ChatItemGalleryFooterContentNode.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1755,7 +1755,6 @@ final class ChatItemGalleryFooterContentNode: GalleryFooterContentNode, ASScroll
17551755
let presentationData = self.context.sharedContext.currentPresentationData.with { $0 }
17561756
let text: String
17571757
if let timestamp {
1758-
//TODO:localize
17591758
let startTimeString: String
17601759
let hours = timestamp / (60 * 60)
17611760
let minutes = timestamp % (60 * 60) / 60
@@ -1765,7 +1764,7 @@ final class ChatItemGalleryFooterContentNode: GalleryFooterContentNode, ASScroll
17651764
} else {
17661765
startTimeString = String(format: "%d:%02d", minutes, seconds)
17671766
}
1768-
text = "Link with start time at \(startTimeString) copied to clipboard."
1767+
text = presentationData.strings.Conversation_VideoTimeLinkCopied(startTimeString).string
17691768
} else {
17701769
text = presentationData.strings.Conversation_LinkCopied
17711770
}

submodules/GalleryUI/Sources/Items/UniversalVideoGalleryItem.swift

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,7 +1076,6 @@ final class UniversalVideoGalleryItemNode: ZoomableContentGalleryItemNode {
10761076

10771077
private var customUnembedWhenPortrait: ((OverlayMediaItemNode) -> Bool)?
10781078

1079-
private var pictureInPictureContent: AnyObject?
10801079
private var nativePictureInPictureContent: AnyObject?
10811080

10821081
private var activePictureInPictureNavigationController: NavigationController?
@@ -1544,10 +1543,6 @@ final class UniversalVideoGalleryItemNode: ZoomableContentGalleryItemNode {
15441543
strongSelf.videoNode?.setBaseRate(playbackRate)
15451544
}
15461545
}
1547-
1548-
if strongSelf.nativePictureInPictureContent == nil {
1549-
strongSelf.setupNativePictureInPicture()
1550-
}
15511546
}
15521547
}
15531548
self.videoNode = videoNode
@@ -2963,19 +2958,29 @@ final class UniversalVideoGalleryItemNode: ZoomableContentGalleryItemNode {
29632958
}
29642959

29652960
@objc func pictureInPictureButtonPressed() {
2966-
if let currentPictureInPictureNode = self.context.sharedContext.mediaManager.currentPictureInPictureNode as? UniversalVideoGalleryItemNode, let currentItem = currentPictureInPictureNode.item, case let .message(currentMessage, _) = currentItem.contentInfo, case let .message(message, _) = self.item?.contentInfo, currentMessage.id == message.id {
2967-
if let controller = self.galleryController() as? GalleryController {
2968-
controller.dismiss(forceAway: true)
2969-
}
2970-
return
2961+
if self.nativePictureInPictureContent == nil {
2962+
self.setupNativePictureInPicture()
29712963
}
29722964

2973-
if #available(iOS 15.0, *) {
2974-
if let nativePictureInPictureContent = self.nativePictureInPictureContent as? NativePictureInPictureContentImpl {
2975-
addAppLogEvent(postbox: self.context.account.postbox, type: "pip_btn", peerId: self.context.account.peerId)
2976-
nativePictureInPictureContent.beginPictureInPicture()
2965+
DispatchQueue.main.async { [weak self] in
2966+
guard let self else {
2967+
return
2968+
}
2969+
2970+
if let currentPictureInPictureNode = self.context.sharedContext.mediaManager.currentPictureInPictureNode as? UniversalVideoGalleryItemNode, let currentItem = currentPictureInPictureNode.item, case let .message(currentMessage, _) = currentItem.contentInfo, case let .message(message, _) = self.item?.contentInfo, currentMessage.id == message.id {
2971+
if let controller = self.galleryController() as? GalleryController {
2972+
controller.dismiss(forceAway: true)
2973+
}
29772974
return
29782975
}
2976+
2977+
if #available(iOS 15.0, *) {
2978+
if let nativePictureInPictureContent = self.nativePictureInPictureContent as? NativePictureInPictureContentImpl {
2979+
addAppLogEvent(postbox: self.context.account.postbox, type: "pip_btn", peerId: self.context.account.peerId)
2980+
nativePictureInPictureContent.beginPictureInPicture()
2981+
return
2982+
}
2983+
}
29792984
}
29802985
}
29812986

submodules/PhotoResources/Sources/PhotoResources.swift

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -524,15 +524,34 @@ private func chatMessageVideoDatas(postbox: Postbox, userLocation: MediaResource
524524
thumbnail = .single(decodedThumbnailData)
525525
}
526526
} else if let thumbnailResource = thumbnailResource {
527-
thumbnail = Signal { subscriber in
528-
let fetchedDisposable = fetchedMediaResource(mediaBox: postbox.mediaBox, userLocation: userLocation, userContentType: customUserContentType ?? MediaResourceUserContentType(file: fileReference.media), reference: fileReference.resourceReference(thumbnailResource), statsCategory: .video).start()
529-
let thumbnailDisposable = postbox.mediaBox.resourceData(thumbnailResource, attemptSynchronously: synchronousLoad).start(next: { next in
530-
subscriber.putNext(next.size == 0 ? nil : try? Data(contentsOf: URL(fileURLWithPath: next.path), options: []))
531-
}, error: subscriber.putError, completed: subscriber.putCompletion)
532-
533-
return ActionDisposable {
534-
fetchedDisposable.dispose()
535-
thumbnailDisposable.dispose()
527+
if autoFetchFullSizeThumbnail, let thumbnailRepresentation = thumbnailRepresentation, (thumbnailRepresentation.dimensions.width > 200 || thumbnailRepresentation.dimensions.height > 200) {
528+
thumbnail = Signal { subscriber in
529+
let fetchedDisposable = fetchedMediaResource(mediaBox: postbox.mediaBox, userLocation: userLocation, userContentType: customUserContentType ?? MediaResourceUserContentType(file: fileReference.media), reference: fileReference.resourceReference(thumbnailRepresentation.resource), statsCategory: .video).start()
530+
let thumbnailDisposable = postbox.mediaBox.resourceData(thumbnailRepresentation.resource, attemptSynchronously: synchronousLoad).start(next: { next in
531+
let data: Data? = next.size == 0 ? nil : try? Data(contentsOf: URL(fileURLWithPath: next.path), options: [])
532+
if let data {
533+
subscriber.putNext(data)
534+
} else {
535+
subscriber.putNext(nil)
536+
}
537+
}, error: subscriber.putError, completed: subscriber.putCompletion)
538+
539+
return ActionDisposable {
540+
fetchedDisposable.dispose()
541+
thumbnailDisposable.dispose()
542+
}
543+
}
544+
} else {
545+
thumbnail = Signal { subscriber in
546+
let fetchedDisposable = fetchedMediaResource(mediaBox: postbox.mediaBox, userLocation: userLocation, userContentType: customUserContentType ?? MediaResourceUserContentType(file: fileReference.media), reference: fileReference.resourceReference(thumbnailResource), statsCategory: .video).start()
547+
let thumbnailDisposable = postbox.mediaBox.resourceData(thumbnailResource, attemptSynchronously: synchronousLoad).start(next: { next in
548+
subscriber.putNext(next.size == 0 ? nil : try? Data(contentsOf: URL(fileURLWithPath: next.path), options: []))
549+
}, error: subscriber.putError, completed: subscriber.putCompletion)
550+
551+
return ActionDisposable {
552+
fetchedDisposable.dispose()
553+
thumbnailDisposable.dispose()
554+
}
536555
}
537556
}
538557
} else {

submodules/SemanticStatusNode/BUILD

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ swift_library(
1616
"//submodules/GZip:GZip",
1717
"//submodules/rlottie:RLottieBinding",
1818
"//submodules/AppBundle:AppBundle",
19-
"//submodules/ManagedAnimationNode:ManagedAnimationNode"
19+
"//submodules/ManagedAnimationNode:ManagedAnimationNode",
20+
"//submodules/Components/HierarchyTrackingLayer",
2021
],
2122
visibility = [
2223
"//visibility:public",

submodules/SemanticStatusNode/Sources/SemanticStatusNode.swift

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import SwiftSignalKit
66
import RLottieBinding
77
import GZip
88
import AppBundle
9+
import HierarchyTrackingLayer
910

1011
public enum SemanticStatusNodeState: Equatable {
1112
public struct ProgressAppearance: Equatable {
@@ -90,7 +91,7 @@ private func svgPath(_ path: StaticString, scale: CGPoint = CGPoint(x: 1.0, y: 1
9091
}
9192

9293
private extension SemanticStatusNodeState {
93-
func context(current: SemanticStatusNodeStateContext?) -> SemanticStatusNodeStateContext {
94+
func context(current: SemanticStatusNodeStateContext?, animated: Bool) -> SemanticStatusNodeStateContext {
9495
switch self {
9596
case .none, .download, .play, .pause, .customIcon:
9697
let icon: SemanticStatusNodeIcon
@@ -114,7 +115,7 @@ private extension SemanticStatusNodeState {
114115
if current.icon == icon {
115116
return current
116117
} else if (current.icon == .play && icon == .pause) || (current.icon == .pause && icon == .play) {
117-
current.icon = icon
118+
current.setIcon(icon: icon, animated: animated)
118119
return current
119120
} else {
120121
return SemanticStatusNodeIconContext(icon: icon)
@@ -376,6 +377,8 @@ public final class SemanticStatusNode: ASControlNode {
376377
private var stateContext: SemanticStatusNodeStateContext
377378
private var appearanceContext: SemanticStatusNodeAppearanceContext
378379

380+
private let hierarchyTrackingLayer: HierarchyTrackingLayer
381+
379382
private var disposable: Disposable?
380383
private var backgroundNodeImage: UIImage?
381384

@@ -391,13 +394,16 @@ public final class SemanticStatusNode: ASControlNode {
391394

392395
public init(backgroundNodeColor: UIColor, foregroundNodeColor: UIColor, image: Signal<(TransformImageArguments) -> DrawingContext?, NoError>? = nil, overlayForegroundNodeColor: UIColor? = nil, cutout: CGRect? = nil) {
393396
self.state = .none
394-
self.stateContext = self.state.context(current: nil)
397+
self.stateContext = self.state.context(current: nil, animated: false)
395398
self.appearanceContext = SemanticStatusNodeAppearanceContext(background: backgroundNodeColor, foreground: foregroundNodeColor, backgroundImage: nil, overlayForeground: overlayForegroundNodeColor, cutout: cutout)
399+
self.hierarchyTrackingLayer = HierarchyTrackingLayer()
396400

397401
super.init()
398402

403+
self.layer.addSublayer(self.hierarchyTrackingLayer)
404+
399405
self.isOpaque = false
400-
self.displaysAsynchronously = true
406+
self.displaysAsynchronously = false
401407

402408
if let image {
403409
self.setBackgroundImage(image, size: CGSize(width: 44.0, height: 44.0))
@@ -420,7 +426,6 @@ public final class SemanticStatusNode: ASControlNode {
420426
animate = true
421427
}
422428
}
423-
424429
if self.stateContext.isAnimating {
425430
animate = true
426431
}
@@ -449,12 +454,15 @@ public final class SemanticStatusNode: ASControlNode {
449454
self.hasState = true
450455
animated = false
451456
}
457+
if !self.hierarchyTrackingLayer.isInHierarchy {
458+
animated = false
459+
}
452460
if self.state != state || self.appearanceContext.cutout != cutout {
453461
self.state = state
454462
let previousStateContext = self.stateContext
455463
let previousAppearanceContext = updateCutout ? self.appearanceContext : nil
456464

457-
self.stateContext = self.state.context(current: self.stateContext)
465+
self.stateContext = self.state.context(current: self.stateContext, animated: animated)
458466
self.stateContext.requestUpdate = { [weak self] in
459467
self?.setNeedsDisplay()
460468
}

0 commit comments

Comments
 (0)