Skip to content

Commit

Permalink
Add board prefs missing value fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
veloce committed Nov 23, 2024
1 parent 0b03540 commit 21462ac
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/src/model/settings/board_preferences.dart
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ class BoardPrefs with _$BoardPrefs implements Serializable {
required bool coordinates,
required bool pieceAnimation,
required bool showMaterialDifference,
@JsonKey(

This comment has been minimized.

Copy link
@tom-anders

tom-anders Nov 23, 2024

Collaborator

So that's what caused the settings being deleted after the update? Maybe that's something we should add to https://github.com/lichess-org/mobile/blob/main/docs/coding_style.md to at least reduce the chance of it happening in the future?

This comment has been minimized.

Copy link
@veloce

veloce Nov 23, 2024

Author Contributor

Yes sure. I should have seen that in the review, that's also the problem. But yeah, each time we add a new property to a pref object the default value must be added.

defaultValue: ClockPosition.right,
unknownEnumValue: ClockPosition.right,
)
required ClockPosition clockPosition,
@JsonKey(
defaultValue: PieceShiftMethod.either,
Expand All @@ -131,7 +135,10 @@ class BoardPrefs with _$BoardPrefs implements Serializable {
/// Whether to enable shape drawings on the board for games and puzzles.
@JsonKey(defaultValue: true) required bool enableShapeDrawings,
@JsonKey(defaultValue: true) required bool magnifyDraggedPiece,
@JsonKey(defaultValue: DragTargetKind.circle)
@JsonKey(
defaultValue: DragTargetKind.circle,
unknownEnumValue: DragTargetKind.circle,
)
required DragTargetKind dragTargetKind,
@JsonKey(
defaultValue: ShapeColor.green,
Expand Down

0 comments on commit 21462ac

Please sign in to comment.