From 882ff9b17966ea4d68a606252cca5bb732612241 Mon Sep 17 00:00:00 2001 From: Mikei386 <44135113+Mikei386@users.noreply.github.com> Date: Thu, 4 Jun 2026 10:56:45 +0200 Subject: [PATCH] Fix initial clip preview selection --- Sources/GrowthLapse/ContentView.swift | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Sources/GrowthLapse/ContentView.swift b/Sources/GrowthLapse/ContentView.swift index 1092560..bc172e1 100644 --- a/Sources/GrowthLapse/ContentView.swift +++ b/Sources/GrowthLapse/ContentView.swift @@ -250,8 +250,13 @@ struct ContentView: View { SettingsStore.save(newSettings) } .onChange(of: processor.project) { project in - if selectedClipID == nil { - selectedClipID = project?.clips.first?.id + guard let project else { + 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 @@ -409,6 +414,7 @@ struct ContentView: View { return VStack(alignment: .leading, spacing: 8) { ClipPreviewView(clip: liveClip) + .id(liveClip.sourcePath) .frame(height: 180) .clipShape(RoundedRectangle(cornerRadius: 6))