Skip to content

Commit f7409e6

Browse files
committed
Fix empty video compression preset sheet
Render compression presets from the current computed feasible option list instead of storing a separate sheet state array. This keeps the Compress button and the modal sheet in sync and prevents the sheet from appearing without any preset buttons even when options are available.
1 parent 5ac5ac5 commit f7409e6

2 files changed

Lines changed: 9 additions & 5 deletions

File tree

Planet/Writer/VideoInfoRow.swift

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ struct VideoInfoRow: View {
3232
@State private var compressionStartedAt: Date?
3333
@State private var compressionFramesPerSecond: Double?
3434
@State private var lastLoggedCompressionProgressStep: Int = -1
35-
@State private var presentableCompressionOptions: [VideoCompressionJob.Option] = []
3635
@State private var isCompressing: Bool = false
3736
@State private var isShowingCompressionOptions: Bool = false
3837

@@ -159,7 +158,7 @@ struct VideoInfoRow: View {
159158
isCompressing
160159
|| videoAttachment.videoCompressionPreset != nil
161160
|| videoInfo == nil
162-
|| availableCompressionOptions.isEmpty
161+
|| feasibleCompressionOptions.isEmpty
163162
}
164163

165164
private var compressButtonHelpText: String {
@@ -168,6 +167,12 @@ struct VideoInfoRow: View {
168167
: "Compress this video."
169168
}
170169

170+
private var feasibleCompressionOptions: [VideoCompressionJob.Option] {
171+
availableCompressionOptions.filter {
172+
compressionStorageAssessment(for: videoAttachment.path, option: $0).decision != .blocked
173+
}
174+
}
175+
171176
@MainActor
172177
private func openCompressionOptions() {
173178
let assessments = availableCompressionOptions.map {
@@ -176,7 +181,6 @@ struct VideoInfoRow: View {
176181
let feasibleOptions = assessments.compactMap { option, assessment in
177182
assessment.decision == .blocked ? nil : option
178183
}
179-
presentableCompressionOptions = feasibleOptions
180184
guard !feasibleOptions.isEmpty else {
181185
let blockingAssessment = assessments
182186
.map(\.1)
@@ -475,7 +479,7 @@ struct VideoInfoRow: View {
475479
}
476480

477481
VStack(spacing: 10) {
478-
ForEach(presentableCompressionOptions) { option in
482+
ForEach(feasibleCompressionOptions) { option in
479483
Button {
480484
startCompression(using: option)
481485
} label: {

Planet/versioning.xcconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
CURRENT_PROJECT_VERSION = 2750
1+
CURRENT_PROJECT_VERSION = 2751

0 commit comments

Comments
 (0)