Add manual feed reordering, synced via iCloud (#760)#5288
Open
dcaspi wants to merge 1 commit into
Open
Conversation
…e#760) Add a per-feed sortIndex (default 0) that: - persists locally in a new sortIndex column on FeedSettingsDatabase (with an idempotent ALTER TABLE migration for older databases), exposed as FeedSettings.sortIndex / Feed.sortIndex; - is honored by the shared sidebar — a new Node comparator orders feeds by (sortIndex, name), folders still last and alphabetical; with every feed at the default 0 this is identical to today's alphabetical order, so there's no migration and no behavior change unless the user reorders; - syncs over CloudKit: a new sortIndex field on the AccountWebFeed record, written by CloudKitAccountZone.saveSortIndexes(for:) (changed-keys merge, so other fields are untouched) and read back in CloudKitAccountZoneDelegate; - is set by dragging a feed within its container in the existing sidebars — Mac NSOutlineView and iOS collection view — which previously snapped back. Account.reorderFeeds(_:in:) applies the new order, posts ChildrenDidChange, and routes to AccountDelegate.reorderFeeds (a default no-op; only the CloudKit delegate overrides it). Helpers: Array<Feed>.reordered(moving:before:) and Container.topLevelFeedsInDisplayOrder(). v1 covers feeds (top level and inside folders); folders themselves still sort alphabetically at the end. Tests added for the database column + migration, the Feed/FeedSettings proxy, Account.reorderFeeds, and the Array<Feed>.reordered helper. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I've been an avid NetNewsWire user for several years and love just about
everything about it. The one feature I've kept wishing for is the ability
to order feeds, so the ones I care about stand out from the noise — so I
decided to help. I've tried to stick to the idioms already in the codebase,
keep the change minimal while still working well, and add tests.
Resolves #760.
What
Feeds in the sidebar can now be reordered by dragging them within their
container (an account's top level, or a folder) — on both Mac and iOS. You
can already drag feeds today; previously the drop just snapped back. The
order is per-feed and syncs across devices on an iCloud account.
How
sortIndex: Int(default0), stored in a newsortIndexcolumn onFeedSettingsDatabase(with an idempotentALTER TABLEmigration for existing databases), exposed viaFeedSettings.sortIndex/Feed.sortIndex— the same pattern aseditedName,externalID, etc.Nodecomparator orders feeds by(sortIndex, name); folders still come last, alphabetically.SidebarTreeControllerDelegateswitches to it — one change, bothplatforms. Because every feed defaults to
sortIndex 0, the nametie-break reproduces today's alphabetical order exactly: no migration
step, and no behavior change for anyone who never drags a feed.
Account.reorderFeeds(_:in:)assigns0..<n,posts
ChildrenDidChange, and calls a newAccountDelegate.reorderFeeds(a default no-op; only
CloudKitAccountDelegateoverrides it — thesortIndexsetter has already persisted locally for every account type).sortIndexfield on theAccountWebFeedCloudKitrecord.
CloudKitAccountZone.saveSortIndexes(for:)writes it with achanged-keys merge (other fields untouched, same as
renameFeed);CloudKitAccountZoneDelegatereads it back on incoming records.SidebarOutlineDataSource)and iOS (
MainFeedCollectionViewController+Drop) handlers: a feed droppedat a new position within its own container now calls
reorderFeeds.Shared helpers:
Array<Feed>.reordered(moving:before:)andContainer.topLevelFeedsInDisplayOrder().Scope
v1 reorders feeds — at the top level and inside folders. Folders themselves
still sort alphabetically at the end. Possible follow-ups: reordering
folders (needs a
FoldersortIndex + anAccountContainerCloudKit field);placing newly-added feeds at the bottom of a manually-ordered container
(today they default to
0, so they land near the top); a "Reset toalphabetical order" command.
Tests
New
XCTestcoverage inAccountTests: thesortIndexcolumn + migrationfrom a pre-
sortIndexschema, theFeed/FeedSettingsproxy + changenotification,
Account.reorderFeeds, andArray<Feed>.reordered. All 105AccountTestspass; both app targets build. Manually verified drag-reorder(top level and in folders, both platforms) and iCloud sync between devices.
Note on the CloudKit schema
The new
sortIndexfield onAccountWebFeedauto-creates in the CloudKitdevelopment environment on first write; it'll need a schema deploy to
production before a release. Adding a field is backward compatible — older
clients just ignore it.
🤖 Generated with Claude Code