mirror of
https://github.com/immich-app/immich.git
synced 2026-03-05 16:33:46 -05:00
* feat: add playbackStyle to local asset entity and related database schema * implement conversion function for playbackStyle in local sync service * implement conversion function for playbackStyle in local sync service * refactor: remove deducedPlaybackStyle from TrashedLocalAssetEntityData * add playbackStyle column to trashed local asset entity * make playbackStyle non-nullable across the mobile codebase * Streamline playbackStyle backfill: - only backfill local assets playbackStyle in flutter/dart code - only update trashed local assets in db migration * bump target database version to 23 and update migration logic for playbackStyle * set playback_style to 0 in merged_asset.drift as its a getter in base asset * run make pigeon * Populate playbackStyle for trashed assets during native migration
64 lines
1.9 KiB
Dart
64 lines
1.9 KiB
Dart
import 'dart:math';
|
|
|
|
import 'package:immich_mobile/domain/models/album/local_album.model.dart';
|
|
import 'package:immich_mobile/domain/models/asset/base_asset.model.dart';
|
|
import 'package:immich_mobile/infrastructure/repositories/db.repository.dart';
|
|
import 'package:immich_mobile/infrastructure/repositories/local_album.repository.dart';
|
|
|
|
class MediumFactory {
|
|
final Drift _db;
|
|
|
|
const MediumFactory(Drift db) : _db = db;
|
|
|
|
LocalAsset localAsset({
|
|
String? id,
|
|
String? name,
|
|
AssetType? type,
|
|
DateTime? createdAt,
|
|
DateTime? updatedAt,
|
|
String? checksum,
|
|
}) {
|
|
final random = Random();
|
|
|
|
return LocalAsset(
|
|
id: id ?? '${random.nextInt(1000000)}',
|
|
name: name ?? 'Asset ${random.nextInt(1000000)}',
|
|
checksum: checksum ?? '${random.nextInt(1000000)}',
|
|
type: type ?? AssetType.image,
|
|
createdAt: createdAt ?? DateTime.fromMillisecondsSinceEpoch(random.nextInt(1000000000)),
|
|
updatedAt: updatedAt ?? DateTime.fromMillisecondsSinceEpoch(random.nextInt(1000000000)),
|
|
playbackStyle: AssetPlaybackStyle.image,
|
|
isEdited: false,
|
|
);
|
|
}
|
|
|
|
LocalAlbum localAlbum({
|
|
String? id,
|
|
String? name,
|
|
DateTime? updatedAt,
|
|
int? assetCount,
|
|
BackupSelection? backupSelection,
|
|
bool? isIosSharedAlbum,
|
|
}) {
|
|
final random = Random();
|
|
|
|
return LocalAlbum(
|
|
id: id ?? '${random.nextInt(1000000)}',
|
|
name: name ?? 'Album ${random.nextInt(1000000)}',
|
|
updatedAt: updatedAt ?? DateTime.fromMillisecondsSinceEpoch(random.nextInt(1000000000)),
|
|
assetCount: assetCount ?? random.nextInt(100),
|
|
backupSelection: backupSelection ?? BackupSelection.none,
|
|
isIosSharedAlbum: isIosSharedAlbum ?? false,
|
|
);
|
|
}
|
|
|
|
T getRepository<T>() {
|
|
switch (T) {
|
|
case const (DriftLocalAlbumRepository):
|
|
return DriftLocalAlbumRepository(_db) as T;
|
|
default:
|
|
throw Exception('Unknown repository: $T');
|
|
}
|
|
}
|
|
}
|