Skip to content

Commit

Permalink
Fix preview crash due to negative width
Browse files Browse the repository at this point in the history
  • Loading branch information
Ceylo committed Nov 3, 2024
1 parent 495b06e commit b8708aa
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions FurAffinity/User/UserGalleryLikeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,25 @@ struct UserGalleryLikeView: View {
}
.listStyle(.plain)
.onChange(of: gallery.previews, initial: true) {
let thumbnailsWidth = geometry.size.width - 28.333
let previews = gallery.previews
prefetchThumbnails(for: previews, availableWidth: thumbnailsWidth)
prefetchAvatars(for: previews)
prefetch(with: geometry)
}
}
}
}
.navigationBarTitleDisplayMode(.inline)
.navigationTitle("\(gallery.displayAuthor)'s \(galleryType)")
}

func prefetch(with geometry: GeometryProxy) {
let thumbnailsWidth = geometry.size.width - 28.333
guard thumbnailsWidth > 0 else {
logger.error("Skipping prefetch due to too small geometry: \(String(describing: geometry.size))")
return
}
let previews = gallery.previews
prefetchThumbnails(for: previews, availableWidth: thumbnailsWidth)
prefetchAvatars(for: previews)
}
}

// MARK: -
Expand Down

0 comments on commit b8708aa

Please sign in to comment.