42 lines
1.1 KiB
Dart
42 lines
1.1 KiB
Dart
/// Cloud-synced app preferences (Home sections + Look ahead).
|
|
library;
|
|
|
|
import 'home_built_in_sections.dart';
|
|
|
|
/// One-per-user prefs row mirrored in PocketBase `app_prefs`.
|
|
class AppCloudPrefs {
|
|
const AppCloudPrefs({
|
|
required this.homeBuiltInSections,
|
|
required this.lookAheadMaxYears,
|
|
});
|
|
|
|
final HomeBuiltInSections homeBuiltInSections;
|
|
final int lookAheadMaxYears;
|
|
|
|
static const defaults = AppCloudPrefs(
|
|
homeBuiltInSections: HomeBuiltInSections.defaults,
|
|
lookAheadMaxYears: 5,
|
|
);
|
|
|
|
AppCloudPrefs copyWith({
|
|
HomeBuiltInSections? homeBuiltInSections,
|
|
int? lookAheadMaxYears,
|
|
}) {
|
|
return AppCloudPrefs(
|
|
homeBuiltInSections:
|
|
homeBuiltInSections ?? this.homeBuiltInSections,
|
|
lookAheadMaxYears: lookAheadMaxYears ?? this.lookAheadMaxYears,
|
|
);
|
|
}
|
|
}
|
|
|
|
/// Prefer local when the user has pending edits; otherwise take remote.
|
|
AppCloudPrefs mergeAppCloudPrefs({
|
|
required AppCloudPrefs local,
|
|
required AppCloudPrefs? remote,
|
|
required bool preferLocal,
|
|
}) {
|
|
if (preferLocal || remote == null) return local;
|
|
return remote;
|
|
}
|