mirror of
https://github.com/immich-app/immich
synced 2026-08-22 13:13:05 +00:00
* chore(mobile): use Drift @DriftAccessor() and collapse some providers * Fix import order * Required formatting
40 lines
1.1 KiB
Dart
40 lines
1.1 KiB
Dart
import 'dart:math';
|
|
|
|
import 'package:immich_mobile/domain/models/album/local_album.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;
|
|
|
|
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 (LocalAlbumRepository):
|
|
return LocalAlbumRepository(_db) as T;
|
|
default:
|
|
throw Exception('Unknown repository: $T');
|
|
}
|
|
}
|
|
}
|