Skip to content

Fix/settings sort bug - #240

Merged
goku-kamehameha merged 2 commits into
devfrom
fix/settings-sort-bug
Aug 15, 2026
Merged

Fix/settings sort bug#240
goku-kamehameha merged 2 commits into
devfrom
fix/settings-sort-bug

Conversation

@JuliusCaesarCrypto

@JuliusCaesarCrypto JuliusCaesarCrypto commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Change Description

Briefly describe what this PR does and why. Keep it short and clear.


Related Platforms

Which platforms are affected by your changes? Check only the ones you actually tested.

  • Android
  • iOS
  • iPad
  • Windows
  • Linux
  • Android TV
  • OpenWrt

Verification Checklist

Make sure the things you checked actually work. It's okay if you didn't test everything.

  • Project builds successfully
  • App runs without crashes on tested platforms
  • VPN connection works correctly
  • No obvious regressions observed
  • Documentation updated (if needed)

Optional (for bigger changes)

  • Added or updated unit / E2E tests
  • Checked security and edge cases

Related Links

Closes #ID.

@JuliusCaesarCrypto JuliusCaesarCrypto self-assigned this Aug 14, 2026
@JuliusCaesarCrypto JuliusCaesarCrypto added the bug Something isn't working label Aug 14, 2026
Copilot AI lite review requested due to automatic review settings August 14, 2026 20:49

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 (vs id) for connection-method items.
  • Tweaks how new flowline items are assigned sortOrder when 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.

Comment on lines 211 to 216
// 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;
}
Comment on lines 221 to 233
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,
Copilot AI review requested due to automatic review settings August 15, 2026 13:30
@goku-kamehameha
goku-kamehameha merged commit 766a66f into dev Aug 15, 2026
1 check passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

  • existsInSaved currently returns true for every flow item as soon as mergedItems contains any navigation item (because the predicate ORs with itemType == '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

  • minSortOrder was 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, but maxSortOrder is only incremented for premium items. This means multiple newly-added non-premium items can end up with the same sortOrder, and all premium items share -1, causing non-deterministic ordering when the list is later sorted by sortOrder.
          final newItem = SettingsFactory.createFlowlineItem(
            label: label,
            description: flowItem['description'] ?? '',
            sortOrder: isPremium ? -1 : maxSortOrder,
            isEnabled: flowItem['enabled'] ?? false,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants