2025-07-02 14:18:37 -05:00
|
|
|
import 'dart:convert';
|
|
|
|
|
|
2026-08-10 14:12:45 -07:00
|
|
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
2025-07-04 13:49:15 -05:00
|
|
|
import 'package:immich_mobile/domain/models/asset/base_asset.model.dart';
|
|
|
|
|
|
2026-08-10 14:12:45 -07:00
|
|
|
part 'memory.model.freezed.dart';
|
|
|
|
|
|
|
|
|
|
// TODO(agg23): Remove enum suffix
|
2025-07-02 14:18:37 -05:00
|
|
|
enum MemoryTypeEnum {
|
|
|
|
|
// do not change this order!
|
|
|
|
|
onThisDay,
|
|
|
|
|
}
|
|
|
|
|
|
2026-08-10 14:12:45 -07:00
|
|
|
@Freezed(fromJson: false, toJson: false)
|
|
|
|
|
abstract class MemoryData with _$MemoryData {
|
|
|
|
|
const MemoryData._();
|
2025-07-29 00:34:03 +05:30
|
|
|
|
2026-08-10 14:12:45 -07:00
|
|
|
const factory MemoryData({required int year}) = _MemoryData;
|
2025-07-02 14:18:37 -05:00
|
|
|
|
|
|
|
|
Map<String, dynamic> toMap() {
|
2025-07-29 00:34:03 +05:30
|
|
|
return <String, dynamic>{'year': year};
|
2025-07-02 14:18:37 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
factory MemoryData.fromMap(Map<String, dynamic> map) {
|
2025-07-29 00:34:03 +05:30
|
|
|
return MemoryData(year: map['year'] as int);
|
2025-07-02 14:18:37 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String toJson() => json.encode(toMap());
|
|
|
|
|
|
2025-07-25 08:07:22 +05:30
|
|
|
factory MemoryData.fromJson(String source) => MemoryData.fromMap(json.decode(source) as Map<String, dynamic>);
|
2025-07-02 14:18:37 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Model for a memory stored in the server
|
2026-08-10 14:12:45 -07:00
|
|
|
// TODO(agg23): DriftMemoryRepository currently mutates `assets`
|
|
|
|
|
@Freezed(makeCollectionsUnmodifiable: false)
|
|
|
|
|
abstract class DriftMemory with _$DriftMemory {
|
|
|
|
|
const factory DriftMemory({
|
|
|
|
|
required String id,
|
|
|
|
|
required DateTime createdAt,
|
|
|
|
|
required DateTime updatedAt,
|
2025-07-02 14:18:37 -05:00
|
|
|
DateTime? deletedAt,
|
2026-08-10 14:12:45 -07:00
|
|
|
required String ownerId,
|
|
|
|
|
required MemoryTypeEnum type,
|
|
|
|
|
required MemoryData data,
|
|
|
|
|
required bool isSaved,
|
|
|
|
|
required DateTime memoryAt,
|
2025-07-02 14:18:37 -05:00
|
|
|
DateTime? seenAt,
|
|
|
|
|
DateTime? showAt,
|
|
|
|
|
DateTime? hideAt,
|
2026-08-10 14:12:45 -07:00
|
|
|
required List<RemoteAsset> assets,
|
|
|
|
|
}) = _DriftMemory;
|
2025-07-02 14:18:37 -05:00
|
|
|
}
|