refactor: migrate models to freezed + json_serializable

This commit is contained in:
edde746
2026-05-11 12:54:26 +02:00
parent 2bbd31d927
commit d0bd919ff4
59 changed files with 9551 additions and 1236 deletions
@@ -64,9 +64,8 @@ class _AddLocalProfileScreenState extends State<AddLocalProfileScreen> with Cont
setState(() => _saving = true);
final registry = context.read<ProfileRegistry>();
final profile = Profile(
final profile = Profile.local(
id: 'local-${const Uuid().v4()}',
kind: ProfileKind.local,
displayName: name,
pinHash: _pinHash,
sortOrder: DateTime.now().millisecondsSinceEpoch,
@@ -87,14 +87,18 @@ class _ProfileDetailScreenState extends State<ProfileDetailScreen> with Controll
onMismatch: (ctx) => showErrorSnackBar(ctx, t.profiles.pinsDontMatch),
);
if (pin == null || !mounted) return;
final updated = _profile.copyWith(pinHash: computePinHash(pin));
final profile = _profile;
if (profile is! LocalProfile) return;
final updated = profile.copyWith(pinHash: computePinHash(pin));
await context.read<ProfileRegistry>().upsert(updated);
if (!mounted) return;
setState(() => _profile = updated);
}
Future<void> _clearPin() async {
final updated = _profile.copyWith(clearPin: true);
final profile = _profile;
if (profile is! LocalProfile) return;
final updated = profile.copyWith(pinHash: null);
await context.read<ProfileRegistry>().upsert(updated);
if (!mounted) return;
setState(() => _profile = updated);
@@ -264,9 +264,8 @@ class _AddJellyfinScreenState extends State<AddJellyfinScreen> with AsyncFormSta
hasProfiles: activeProvider.profiles.isNotEmpty,
)) {
final now = DateTime.now();
final profile = Profile(
final profile = Profile.local(
id: 'local-${const Uuid().v4()}',
kind: ProfileKind.local,
displayName: connection.userName.isNotEmpty ? connection.userName : connection.serverName,
sortOrder: now.millisecondsSinceEpoch,
createdAt: now,