refactor: migrate models to freezed + json_serializable
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user