Skip to content

Conversation

@chizberg
Copy link
Owner

No description provided.

@chizberg chizberg requested a review from Copilot January 10, 2026 23:21
@chizberg chizberg linked an issue Jan 10, 2026 that may be closed by this pull request
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request adds image sorting support to the Rewind app, allowing users to sort images by date (ascending or descending) or shuffle them randomly. The feature integrates sorting into the image list view with a toolbar menu picker and persists the user's preference in settings.

Changes:

  • Added new ImageSorting enum with three sorting options: date ascending, date descending, and shuffle
  • Integrated sorting UI into the image list toolbar with a menu picker
  • Added sorting preference to app settings with persistence
  • Updated localization files with new sorting-related strings in English, Russian, Serbian (Latin), and Ukrainian

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
Rewind/Model/ImageSorting.swift New file defining sorting enum and array extension for sorting images
Rewind/View/ImageList.swift Added toolbar with sorting menu picker and localized labels for sorting options
Rewind/Model/SettingsViewModel.swift Added sorting property to settings state with default value and decoding logic
Rewind/Model/MapModel.swift Integrated sorting into map model to sort current region images
Rewind/Model/ImageListModel.swift Added sorting state and action handling to image list model
Rewind/Model/AppModel.swift Updated to pass sorting property to image list models
Rewind/Model/AppGraph.swift Wired up sorting property and added observer to update previews on sorting changes
Rewind/Localizable.xcstrings Added localized strings for sorting options and menu in 4 languages

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 11 to 19
case dateAccending
case dateDescending
case shuffle
}

extension [Model.Image] {
func sorted(by sorting: ImageSorting) -> [Model.Image] {
switch sorting {
case .dateAccending: sorted { $0.date.year < $1.date.year }
Copy link

Copilot AI Jan 10, 2026

Choose a reason for hiding this comment

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

The spelling of "Ascending" is incorrect. It should be "Ascending" instead of "Accending" in the enum case name. This typo appears in the enum case definition and will propagate throughout the codebase.

Suggested change
case dateAccending
case dateDescending
case shuffle
}
extension [Model.Image] {
func sorted(by sorting: ImageSorting) -> [Model.Image] {
switch sorting {
case .dateAccending: sorted { $0.date.year < $1.date.year }
case dateAscending
case dateDescending
case shuffle
}
extension [Model.Image] {
func sorted(by sorting: ImageSorting) -> [Model.Image] -> [Model.Image] {
switch sorting {
case .dateAscending: sorted { $0.date.year < $1.date.year }

Copilot uses AI. Check for mistakes.

fileprivate var title: LocalizedStringKey {
switch self {
case .dateAccending: "Date Ascending"
Copy link

Copilot AI Jan 10, 2026

Choose a reason for hiding this comment

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

The spelling of "Ascending" is incorrect. It should be "Ascending" instead of "Accending". This typo is used consistently with the misspelled enum case name.

Copilot uses AI. Check for mistakes.
listUpdates: .empty,
imageDetailsFactory: imageDetailsFactoryMock
imageDetailsFactory: imageDetailsFactoryMock,
sorting: .constant(.dateAccending)
Copy link

Copilot AI Jan 10, 2026

Choose a reason for hiding this comment

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

The spelling of "Ascending" is incorrect. It should be "Ascending" instead of "Accending". This typo is used consistently with the misspelled enum case name.

Copilot uses AI. Check for mistakes.
extension [Model.Image] {
func sorted(by sorting: ImageSorting) -> [Model.Image] {
switch sorting {
case .dateAccending: sorted { $0.date.year < $1.date.year }
Copy link

Copilot AI Jan 10, 2026

Choose a reason for hiding this comment

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

The spelling of "Ascending" is incorrect. It should be "Ascending" instead of "Accending". This typo is used consistently with the misspelled enum case name.

Copilot uses AI. Check for mistakes.
Comment on lines +59 to +60
sorting?.value = newSorting
state.images = state.images.sorted(by: newSorting)
Copy link

Copilot AI Jan 10, 2026

Choose a reason for hiding this comment

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

The Picker's selection binding creates a new ImageSorting value on each change, but the guard statement on line 57 checks if the sorting hasn't changed before proceeding. However, since enums are value types and the comparison should work correctly, this is acceptable. Still, consider whether the setter should be called before or after the guard check to ensure proper state synchronization.

Suggested change
sorting?.value = newSorting
state.images = state.images.sorted(by: newSorting)
state.images = state.images.sorted(by: newSorting)
sorting?.value = newSorting

Copilot uses AI. Check for mistakes.

fileprivate var iconName: String {
switch self {
case .dateAccending: "arrow.up"
Copy link

Copilot AI Jan 10, 2026

Choose a reason for hiding this comment

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

The spelling of "Ascending" is incorrect. It should be "Ascending" instead of "Accending". This typo is used consistently with the misspelled enum case name.

Copilot uses AI. Check for mistakes.
listUpdates: .empty,
imageDetailsFactory: imageDetailsFactoryMock
imageDetailsFactory: imageDetailsFactoryMock,
sorting: .constant(.dateAccending)
Copy link

Copilot AI Jan 10, 2026

Choose a reason for hiding this comment

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

The spelling of "Ascending" is incorrect. It should be "Ascending" instead of "Accending". This typo is used consistently with the misspelled enum case name.

Copilot uses AI. Check for mistakes.
showYearColorInClusters: true,
openClusterPreviews: false
openClusterPreviews: false,
sorting: .dateAccending
Copy link

Copilot AI Jan 10, 2026

Choose a reason for hiding this comment

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

The spelling of "Ascending" is incorrect. It should be "Ascending" instead of "Accending". This typo is used consistently with the misspelled enum case name.

Copilot uses AI. Check for mistakes.
self.openClusterPreviews = try container.decode(Bool.self, forKey: .openClusterPreviews)

self.sorting = try container
.decodeIfPresent(ImageSorting.self, forKey: .sorting) ?? .dateAccending
Copy link

Copilot AI Jan 10, 2026

Choose a reason for hiding this comment

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

The spelling of "Ascending" is incorrect. It should be "Ascending" instead of "Accending". This typo is used consistently with the misspelled enum case name.

Copilot uses AI. Check for mistakes.
Comment on lines 19 to 20
case .dateAccending: sorted { $0.date.year < $1.date.year }
case .dateDescending: sorted { $0.date.year > $1.date.year }
Copy link

Copilot AI Jan 10, 2026

Choose a reason for hiding this comment

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

The sorting implementation only considers the start year (year) and not the end year (year2). For images with date ranges, this may lead to inaccurate sorting. Consider comparing year2 as a tiebreaker when year values are equal, or using the average/midpoint of the range for more accurate chronological ordering.

Suggested change
case .dateAccending: sorted { $0.date.year < $1.date.year }
case .dateDescending: sorted { $0.date.year > $1.date.year }
case .dateAccending:
sorted {
let lhs = ($0.date.year, $0.date.year2 ?? $0.date.year)
let rhs = ($1.date.year, $1.date.year2 ?? $1.date.year)
return lhs < rhs
}
case .dateDescending:
sorted {
let lhs = ($0.date.year, $0.date.year2 ?? $0.date.year)
let rhs = ($1.date.year, $1.date.year2 ?? $1.date.year)
return lhs > rhs
}

Copilot uses AI. Check for mistakes.
@chizberg chizberg merged commit 4cea669 into main Jan 11, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Option to sort images by year

2 participants