activity.model.dart 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. import 'package:immich_mobile/shared/models/user.dart';
  2. import 'package:openapi/api.dart';
  3. enum ActivityType { comment, like }
  4. class Activity {
  5. final String id;
  6. final String? assetId;
  7. final String? comment;
  8. final DateTime createdAt;
  9. final ActivityType type;
  10. final User user;
  11. const Activity({
  12. required this.id,
  13. this.assetId,
  14. this.comment,
  15. required this.createdAt,
  16. required this.type,
  17. required this.user,
  18. });
  19. Activity copyWith({
  20. String? id,
  21. String? assetId,
  22. String? comment,
  23. DateTime? createdAt,
  24. ActivityType? type,
  25. User? user,
  26. }) {
  27. return Activity(
  28. id: id ?? this.id,
  29. assetId: assetId ?? this.assetId,
  30. comment: comment ?? this.comment,
  31. createdAt: createdAt ?? this.createdAt,
  32. type: type ?? this.type,
  33. user: user ?? this.user,
  34. );
  35. }
  36. Activity.fromDto(ActivityResponseDto dto)
  37. : id = dto.id,
  38. assetId = dto.assetId,
  39. comment = dto.comment,
  40. createdAt = dto.createdAt,
  41. type = dto.type == ActivityResponseDtoTypeEnum.comment
  42. ? ActivityType.comment
  43. : ActivityType.like,
  44. user = User(
  45. email: dto.user.email,
  46. firstName: dto.user.firstName,
  47. lastName: dto.user.lastName,
  48. profileImagePath: dto.user.profileImagePath,
  49. id: dto.user.id,
  50. // Placeholder values
  51. isAdmin: false,
  52. updatedAt: DateTime.now(),
  53. isPartnerSharedBy: false,
  54. isPartnerSharedWith: false,
  55. memoryEnabled: false,
  56. );
  57. @override
  58. String toString() {
  59. return 'Activity(id: $id, assetId: $assetId, comment: $comment, createdAt: $createdAt, type: $type, user: $user)';
  60. }
  61. @override
  62. bool operator ==(Object other) {
  63. if (identical(this, other)) return true;
  64. return other is Activity &&
  65. other.id == id &&
  66. other.assetId == assetId &&
  67. other.comment == comment &&
  68. other.createdAt == createdAt &&
  69. other.type == type &&
  70. other.user == user;
  71. }
  72. @override
  73. int get hashCode {
  74. return id.hashCode ^
  75. assetId.hashCode ^
  76. comment.hashCode ^
  77. createdAt.hashCode ^
  78. type.hashCode ^
  79. user.hashCode;
  80. }
  81. }