Fix initial clip preview selection

This commit is contained in:
Mikei386
2026-06-04 10:56:45 +02:00
parent 0d7f9aa83f
commit 882ff9b179
+8 -2
View File
@@ -250,8 +250,13 @@ struct ContentView: View {
SettingsStore.save(newSettings) SettingsStore.save(newSettings)
} }
.onChange(of: processor.project) { project in .onChange(of: processor.project) { project in
if selectedClipID == nil { guard let project else {
selectedClipID = project?.clips.first?.id selectedClipID = nil
return
}
let orderedClips = orderedProjectClips(project.clips)
if selectedClipID == nil || !orderedClips.contains(where: { $0.id == selectedClipID }) {
selectedClipID = orderedClips.first?.id
} }
} }
.onChange(of: settings.sortMode) { sortMode in .onChange(of: settings.sortMode) { sortMode in
@@ -409,6 +414,7 @@ struct ContentView: View {
return VStack(alignment: .leading, spacing: 8) { return VStack(alignment: .leading, spacing: 8) {
ClipPreviewView(clip: liveClip) ClipPreviewView(clip: liveClip)
.id(liveClip.sourcePath)
.frame(height: 180) .frame(height: 180)
.clipShape(RoundedRectangle(cornerRadius: 6)) .clipShape(RoundedRectangle(cornerRadius: 6))