Skip to content

Commit d5139b6

Browse files
committed
Various fixes
1 parent 999f8c8 commit d5139b6

File tree

2 files changed

+30
-6
lines changed

2 files changed

+30
-6
lines changed

submodules/TelegramUI/Components/MediaEditorScreen/Sources/MediaEditorScreen.swift

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2021,8 +2021,12 @@ final class MediaEditorScreenComponent: Component {
20212021
if case .avatarEditor = controller.mode {
20222022
maxDuration = 9.9
20232023
} else {
2024-
maxDuration = storyMaxCombinedVideoDuration
2025-
segmentDuration = storyMaxVideoDuration
2024+
if controller.node.items.count > 0 {
2025+
maxDuration = storyMaxVideoDuration
2026+
} else {
2027+
maxDuration = storyMaxCombinedVideoDuration
2028+
segmentDuration = storyMaxVideoDuration
2029+
}
20262030
}
20272031
}
20282032

@@ -3506,7 +3510,10 @@ public final class MediaEditorScreenImpl: ViewController, MediaEditorScreen, UID
35063510
values: initialValues,
35073511
hasHistogram: true
35083512
)
3509-
mediaEditor.maxDuration = storyMaxCombinedVideoDuration
3513+
if case .storyEditor = controller.mode, self.items.isEmpty {
3514+
mediaEditor.maxDuration = storyMaxCombinedVideoDuration
3515+
}
3516+
35103517
if case .avatarEditor = controller.mode {
35113518
mediaEditor.setVideoIsMuted(true)
35123519
} else if case let .coverEditor(dimensions) = controller.mode {
@@ -6801,9 +6808,26 @@ public final class MediaEditorScreenImpl: ViewController, MediaEditorScreen, UID
68016808
coverImage = nil
68026809
}
68036810

6811+
var storyCount: Int32 = 0
6812+
if self.node.items.count > 0 {
6813+
storyCount = Int32(self.node.items.count(where: { $0.isEnabled }))
6814+
} else {
6815+
if case let .asset(asset) = self.node.subject {
6816+
let duration: Double
6817+
if let playerDuration = mediaEditor.duration {
6818+
duration = playerDuration
6819+
} else {
6820+
duration = asset.duration
6821+
}
6822+
if duration > storyMaxVideoDuration {
6823+
storyCount = Int32(min(storyMaxCombinedVideoCount, Int(ceil(duration / storyMaxVideoDuration))))
6824+
}
6825+
}
6826+
}
6827+
68046828
let stateContext = ShareWithPeersScreen.StateContext(
68056829
context: self.context,
6806-
subject: .stories(editing: false, count: Int32(self.node.items.count(where: { $0.isEnabled }))),
6830+
subject: .stories(editing: false, count: storyCount),
68076831
editing: false,
68086832
initialPeerIds: Set(privacy.privacy.additionallyIncludePeers),
68096833
closeFriends: self.closeFriends.get(),
@@ -8151,7 +8175,7 @@ public final class MediaEditorScreenImpl: ViewController, MediaEditorScreen, UID
81518175

81528176
let storyCount = min(storyMaxCombinedVideoCount, Int(ceil(duration / storyMaxVideoDuration)))
81538177
var start = values.videoTrimRange?.lowerBound ?? 0
8154-
for _ in 0 ..< storyCount {
8178+
for i in 0 ..< storyCount {
81558179
let trimmedValues = values.withUpdatedVideoTrimRange(start ..< min(start + storyMaxVideoDuration, originalDuration))
81568180

81578181
var editingItem = EditingItem(asset: asset)

submodules/TelegramUI/Components/MediaScrubberComponent/Sources/MediaScrubberComponent.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1510,7 +1510,7 @@ private class TrackView: UIView, UIScrollViewDelegate, UIGestureRecognizerDelega
15101510

15111511
var validIds = Set<Int32>()
15121512
var segmentFrame = CGRect(x: segmentOrigin + segmentWidth, y: 0.0, width: 1.0, height: containerFrame.size.height)
1513-
for i in 0 ..< segmentCount {
1513+
for i in 0 ..< min(segmentCount, 2) {
15141514
let id = Int32(i)
15151515
validIds.insert(id)
15161516

0 commit comments

Comments
 (0)