Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 11 additions & 15 deletions Sources/FlowStack/FlowLink.swift
Original file line number Diff line number Diff line change
Expand Up @@ -365,13 +365,14 @@ public struct FlowLink<Label>: View where Label: View {
.onButtonGesture {
buttonPressed = true
// check for sibling elements and return early if we already have a presented element at this depth
guard !hasSiblingElement else {
return
}
guard !hasSiblingElement else { return }
Task {
if configuration.transitionFromSnapshot {
context?.snapshot = snapshots[colorScheme]
initSnapshots()
self.context?.snapshotDict = snapshots
self.context?.snapshot = snapshots[colorScheme]
}

if let value = value {
withTransaction(transaction) {
path?.wrappedValue.append(value, context: context)
Expand Down Expand Up @@ -402,11 +403,9 @@ public struct FlowLink<Label>: View where Label: View {
}
}
.onChange(of: colorScheme) { newScheme in
refreshButton = UUID()
snapshots[newScheme]
path?.wrappedValue.updateSnapshots(from: newScheme)
refreshButton = UUID()
}
.onAppear { initSnapshots() }
.background(
GeometryReader { proxy in
Color.clear
Expand Down Expand Up @@ -460,14 +459,11 @@ public struct FlowLink<Label>: View where Label: View {
}

private func initSnapshots() {
Task {
// Prevent Snapshot from being taken too early before Fetchable content loads
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❓ Is this not a concern anymore? Seems like it would still be an issue.

Copy link
Collaborator Author

@brody2002 brody2002 Jul 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zac

I was loading snapshots using .task{} . This proved to be very bad so I changed it to happen through the button tap.

try? await Task.sleep(10000)
let lightImage = createSnapshot(colorScheme: .light)
let darkImage = createSnapshot(colorScheme: .dark)
snapshots[.light] = lightImage
snapshots[.dark] = darkImage
}
guard snapshots.isEmpty else { return }
let lightImage = createSnapshot(colorScheme: .light)
let darkImage = createSnapshot(colorScheme: .dark)
self.snapshots[.light] = lightImage
self.snapshots[.dark] = darkImage
}
}

Expand Down
Loading