activity.model.dart 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. name: dto.user.name,
  47. profileImagePath: dto.user.profileImagePath,
  48. id: dto.user.id,
  49. // Placeholder values
  50. isAdmin: false,
  51. updatedAt: DateTime.now(),
  52. isPartnerSharedBy: false,
  53. isPartnerSharedWith: false,
  54. memoryEnabled: false,
  55. );
  56. @override
  57. String toString() {
  58. return 'Activity(id: $id, assetId: $assetId, comment: $comment, createdAt: $createdAt, type: $type, user: $user)';
  59. }
  60. @override
  61. bool operator ==(Object other) {
  62. if (identical(this, other)) return true;
  63. return other is Activity &&
  64. other.id == id &&
  65. other.assetId == assetId &&
  66. other.comment == comment &&
  67. other.createdAt == createdAt &&
  68. other.type == type &&
  69. other.user == user;
  70. }
  71. @override
  72. int get hashCode {
  73. return id.hashCode ^
  74. assetId.hashCode ^
  75. comment.hashCode ^
  76. createdAt.hashCode ^
  77. type.hashCode ^
  78. user.hashCode;
  79. }
  80. }