Sync previews when clip source changes
This commit is contained in:
@@ -603,6 +603,9 @@ private struct ClipPreviewView: View {
|
||||
.onChange(of: clip.id) { _ in
|
||||
loadClip()
|
||||
}
|
||||
.onChange(of: clip.sourcePath) { _ in
|
||||
loadClip()
|
||||
}
|
||||
.onChange(of: clip.segmentStart) { _ in
|
||||
seekToSegmentStart()
|
||||
}
|
||||
@@ -708,6 +711,7 @@ private struct ClipVariantPickerView: View {
|
||||
|
||||
if let selectedVariant {
|
||||
VariantPreviewView(variant: selectedVariant)
|
||||
.id(selectedVariant.sourcePath)
|
||||
.frame(height: 220)
|
||||
.clipShape(RoundedRectangle(cornerRadius: 8))
|
||||
}
|
||||
@@ -745,8 +749,19 @@ private struct ClipVariantPickerView: View {
|
||||
}
|
||||
.padding()
|
||||
.onAppear {
|
||||
selectedVariantID = selectedVariant?.id
|
||||
selectedVariantID = currentVariantID()
|
||||
}
|
||||
.onChange(of: clip.id) { _ in
|
||||
selectedVariantID = currentVariantID()
|
||||
}
|
||||
.onChange(of: clip.sourcePath) { _ in
|
||||
selectedVariantID = currentVariantID()
|
||||
}
|
||||
}
|
||||
|
||||
private func currentVariantID() -> UUID? {
|
||||
clip.availableVariants.first(where: { $0.sourcePath == clip.sourcePath })?.id
|
||||
?? clip.availableVariants.first?.id
|
||||
}
|
||||
|
||||
private func format(_ value: Double) -> String {
|
||||
@@ -770,6 +785,9 @@ private struct VariantPreviewView: View {
|
||||
.onChange(of: variant.id) { _ in
|
||||
loadVariant()
|
||||
}
|
||||
.onChange(of: variant.sourcePath) { _ in
|
||||
loadVariant()
|
||||
}
|
||||
}
|
||||
|
||||
private func loadVariant() {
|
||||
|
||||
Reference in New Issue
Block a user