Skip to content

Add alphabetical sort toggle to puzzle openings screen#3045

Merged
veloce merged 2 commits into
lichess-org:mainfrom
adharshio:fix/puzzle-openings-alphabetical-sort
May 19, 2026
Merged

Add alphabetical sort toggle to puzzle openings screen#3045
veloce merged 2 commits into
lichess-org:mainfrom
adharshio:fix/puzzle-openings-alphabetical-sort

Conversation

@adharshio

Copy link
Copy Markdown
Contributor

Fixes #2981

  • Add sort toggle button in app bar (popular ↔ alphabetical)
  • Sort is done client-side as the server endpoint does not support order param
  • puzzleOpeningsProvider is now a family provider keyed by sort order
  • Both orders are cached separately for 1 day

@veloce

veloce commented Apr 25, 2026

Copy link
Copy Markdown
Contributor

Can you see why tests are failing @adharshio ? thanks!

@adharshio adharshio force-pushed the fix/puzzle-openings-alphabetical-sort branch from bb256b7 to 12c57f9 Compare April 25, 2026 10:35
@adharshio

Copy link
Copy Markdown
Contributor Author

Hi @veloce, the test failures were due to stale generated files (tv_controller.freezed.dart). Running dart run build_runner build --delete-conflicting-outputs fixed it — all 814 tests pass locally now.i have pushed it now.

@adharshio

Copy link
Copy Markdown
Contributor Author

hi @veloce . what do you think of this ? would love to have any suggestion ...

@veloce

veloce commented May 4, 2026

Copy link
Copy Markdown
Contributor

@adharshio can we have a screen recording showing how this new feature works? Thanks.

@ijm8710

ijm8710 commented May 4, 2026

Copy link
Copy Markdown

@adharshio can we have a screen recording showing how this new feature works? Thanks.

Veloce he included one here #3019

He just reopened as a new pr to clean up the commit history

final puzzleOpeningsProvider = FutureProvider.autoDispose<IList<PuzzleOpeningFamily>>((Ref ref) {
final puzzleOpeningsProvider = FutureProvider.autoDispose.family<IList<PuzzleOpeningFamily>, bool>((
Ref ref,
bool alphabetical,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Instead of the boolean, I'd rather see an enum. It is a stronger type and clearer at the same time.

enum PuzzleOpeningSort { popular, alphabetical }

Comment thread lib/src/view/puzzle/opening_screen.dart Outdated
title: Text(context.l10n.puzzlePuzzlesByOpenings),
actions: [
IconButton(
icon: Icon(isAlphabetical ? Icons.sort_by_alpha : Icons.trending_up),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The trending_up icon is not ideal here.

Instead of having 2 icons to represent which sorting is chosen, prefer having a unique Icons.sort_outlined that opens a context menu that allows you to choose between both sorting options.

See study_list_screen.dart for an example.

@adharshio

Copy link
Copy Markdown
Contributor Author

I am so sorry for the delay...will start this as soon as I can.

Fixes lichess-org#2981

- Add sort toggle button in app bar (popular ↔ alphabetical)
- Sort is done client-side as the server endpoint does not support order param
- puzzleOpeningsProvider is now a family provider keyed by sort order
- Both orders are cached separately for 1 day
@adharshio adharshio force-pushed the fix/puzzle-openings-alphabetical-sort branch from 0316a9f to aea8f0e Compare May 17, 2026 04:06
@adharshio

adharshio commented May 17, 2026

Copy link
Copy Markdown
Contributor Author

replaced bool with enum PuzzleOpeningSort { popular, alphabetical and replaced with ContextMenuIconButton using Icons.sort_outlined that opens a context menu with both options.
Here is screen recording showing the changes:

sorted_opening.mp4

@veloce veloce left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thank you!

@veloce veloce merged commit bedabb0 into lichess-org:main May 19, 2026
1 check 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.

sort openings alphabetically

3 participants