chore(mobile): simple freezed implementation on some models (#30168)

* chore(mobile): example freezed implementation on some models

* Don't commit Freezed generated code

* Freezed easy pass

* Formatting fix

* Generate Flutter debugging info
This commit is contained in:
Adam Gastineau 2026-08-05 12:00:49 -07:00 committed by GitHub
parent f11d8b6a5a
commit 18d4a796bb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
36 changed files with 512 additions and 1983 deletions

View file

@ -1,65 +1,21 @@
import 'package:flutter/foundation.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:immich_mobile/domain/models/user.model.dart';
part 'activity.model.freezed.dart';
enum ActivityType { comment, like }
class Activity {
final String id;
final String? assetId;
final String? comment;
final DateTime createdAt;
final ActivityType type;
final UserDto user;
const Activity({
required this.id,
this.assetId,
this.comment,
required this.createdAt,
required this.type,
required this.user,
});
Activity copyWith({
String? id,
@freezed
abstract class Activity with _$Activity {
const factory Activity({
required String id,
String? assetId,
String? comment,
DateTime? createdAt,
ActivityType? type,
UserDto? user,
}) {
return Activity(
id: id ?? this.id,
assetId: assetId ?? this.assetId,
comment: comment ?? this.comment,
createdAt: createdAt ?? this.createdAt,
type: type ?? this.type,
user: user ?? this.user,
);
}
@override
String toString() {
return 'Activity(id: $id, assetId: $assetId, comment: $comment, createdAt: $createdAt, type: $type, user: $user)';
}
@override
bool operator ==(covariant Activity other) {
if (identical(this, other)) {
return true;
}
return other.id == id &&
other.assetId == assetId &&
other.comment == comment &&
other.createdAt == createdAt &&
other.type == type &&
other.user == user;
}
@override
int get hashCode {
return id.hashCode ^ assetId.hashCode ^ comment.hashCode ^ createdAt.hashCode ^ type.hashCode ^ user.hashCode;
}
required DateTime createdAt,
required ActivityType type,
required UserDto user,
}) = _Activity;
}
class ActivityStats {