Fix/settings sort bug - #240
Conversation
There was a problem hiding this comment.
Pull request overview
This PR aims to fix ordering/merging behavior for the Settings → connection method items by reconciling saved settings with the flowline source-of-truth, so newly introduced items appear in a consistent order. It also includes incidental dependency / CocoaPods lockfile and Xcode project updates.
Changes:
- Adjusts flowline-to-saved-item matching to use
title(vsid) for connection-method items. - Tweaks how new flowline items are assigned
sortOrderwhen merging into saved settings (including premium handling). - Updates FlutterFire/Firebase dependency locks and iOS CocoaPods/Xcode project references.
Reviewed changes
Copilot reviewed 3 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| pubspec.lock | Updates Flutter/Dart dependency lock entries (notably FlutterFire packages). |
| lib/modules/settings/providers/settings_provider.dart | Updates merge logic for saved vs flowline connection-method settings and sort order assignment. |
| lib/modules/settings/presentation/widgets/settings_group_widget.dart | Minor formatting change for AppLocalizations.of(context) call. |
| ios/Runner.xcodeproj/project.pbxproj | Regenerates/updates CocoaPods build phase and file reference IDs in the Xcode project. |
| ios/Podfile.lock | Updates iOS pods (notably Firebase) and CocoaPods version recorded in the lockfile. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| // Find max sortOrder from existing items | ||
| int maxSortOrder = 0; | ||
| int minSortOrder = allFlowlineItems.length; | ||
| for (var item in mergedItems) { | ||
| final order = item['sortOrder'] as int? ?? 0; | ||
| if (order > maxSortOrder) maxSortOrder = order; | ||
| if (order < minSortOrder) minSortOrder = order; | ||
| } |
| final existsInSaved = mergedItems.any( | ||
| (settingItem) => | ||
| settingItem['id'] == label || | ||
| settingItem['title'] == label || | ||
| settingItem['itemType'] == 'navigation', | ||
| ); | ||
|
|
||
| if (!existsInSaved) { | ||
| final isPremium = flowItem['isPremium'] ?? false; | ||
| if (isPremium) { | ||
| maxSortOrder++; | ||
| } else { | ||
| minSortOrder--; | ||
| } | ||
|
|
||
| final newItem = SettingsFactory.createFlowlineItem( | ||
| label: label, | ||
| description: flowItem['description'] ?? '', | ||
| sortOrder: isPremium ? minSortOrder : maxSortOrder, | ||
| sortOrder: isPremium ? -1 : maxSortOrder, | ||
| isEnabled: flowItem['enabled'] ?? false, |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 5 changed files in this pull request and generated no new comments.
Suppressed comments (3)
lib/modules/settings/providers/settings_provider.dart:225
existsInSavedcurrently returns true for every flow item as soon asmergedItemscontains any navigation item (because the predicate ORs withitemType == 'navigation'). This prevents missing flowline items from being added when a navigation item (e.g., Destination) is present in saved settings.
final existsInSaved = mergedItems.any(
(settingItem) =>
settingItem['title'] == label ||
settingItem['itemType'] == 'navigation',
);
lib/modules/settings/providers/settings_provider.dart:215
minSortOrderwas removed, but the merge logic still needs a stable lower bound for inserting new premium items ahead of existing items. Without tracking the minimum, assigning a constant sort order (e.g., -1) can lead to ties and unstable ordering after the subsequent sort-by-sortOrder.
// Find max sortOrder from existing items
int maxSortOrder = 0;
for (var item in mergedItems) {
final order = item['sortOrder'] as int? ?? 0;
if (order > maxSortOrder) maxSortOrder = order;
lib/modules/settings/providers/settings_provider.dart:233
- New items are created with
sortOrder: isPremium ? -1 : maxSortOrder, butmaxSortOrderis only incremented for premium items. This means multiple newly-added non-premium items can end up with the samesortOrder, and all premium items share -1, causing non-deterministic ordering when the list is later sorted bysortOrder.
final newItem = SettingsFactory.createFlowlineItem(
label: label,
description: flowItem['description'] ?? '',
sortOrder: isPremium ? -1 : maxSortOrder,
isEnabled: flowItem['enabled'] ?? false,
Change Description
Briefly describe what this PR does and why. Keep it short and clear.
Related Platforms
Verification Checklist
Optional (for bigger changes)
Related Links
Closes #ID.