mirror of
https://github.com/immich-app/immich.git
synced 2026-04-16 07:31:55 -04:00
* refactor: yank old timeline # Conflicts: # mobile/lib/presentation/pages/editing/drift_edit.page.dart # mobile/lib/providers/websocket.provider.dart # mobile/lib/routing/router.dart * more cleanup * remove native code * chore: bump sqlite-data version * remove old background tasks from BGTaskSchedulerPermittedIdentifiers * rebase --------- Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com>
73 lines
2.3 KiB
Dart
73 lines
2.3 KiB
Dart
import 'package:immich_mobile/domain/models/asset/base_asset.model.dart';
|
|
import 'package:immich_mobile/domain/models/exif.model.dart';
|
|
import 'package:immich_mobile/extensions/string_extensions.dart';
|
|
import 'package:immich_mobile/infrastructure/utils/exif.converter.dart';
|
|
import 'package:openapi/api.dart' as api;
|
|
|
|
extension DTOToAsset on api.AssetResponseDto {
|
|
RemoteAsset toDto() {
|
|
return RemoteAsset(
|
|
id: id,
|
|
name: originalFileName,
|
|
checksum: checksum,
|
|
createdAt: fileCreatedAt,
|
|
updatedAt: updatedAt,
|
|
ownerId: ownerId,
|
|
visibility: visibility.toAssetVisibility(),
|
|
durationInSeconds: duration.toDuration()?.inSeconds ?? 0,
|
|
height: height?.toInt(),
|
|
width: width?.toInt(),
|
|
isFavorite: isFavorite,
|
|
livePhotoVideoId: livePhotoVideoId,
|
|
thumbHash: thumbhash,
|
|
localId: null,
|
|
type: type.toAssetType(),
|
|
stackId: stack?.id,
|
|
isEdited: isEdited,
|
|
);
|
|
}
|
|
|
|
RemoteAssetExif toDtoWithExif() {
|
|
return RemoteAssetExif(
|
|
id: id,
|
|
name: originalFileName,
|
|
checksum: checksum,
|
|
createdAt: fileCreatedAt,
|
|
updatedAt: updatedAt,
|
|
ownerId: ownerId,
|
|
visibility: visibility.toAssetVisibility(),
|
|
durationInSeconds: duration.toDuration()?.inSeconds ?? 0,
|
|
height: height?.toInt(),
|
|
width: width?.toInt(),
|
|
isFavorite: isFavorite,
|
|
livePhotoVideoId: livePhotoVideoId,
|
|
thumbHash: thumbhash,
|
|
localId: null,
|
|
type: type.toAssetType(),
|
|
stackId: stack?.id,
|
|
isEdited: isEdited,
|
|
exifInfo: exifInfo != null ? ExifDtoConverter.fromDto(exifInfo!) : const ExifInfo(),
|
|
);
|
|
}
|
|
}
|
|
|
|
extension on api.AssetVisibility {
|
|
AssetVisibility toAssetVisibility() => switch (this) {
|
|
api.AssetVisibility.timeline => AssetVisibility.timeline,
|
|
api.AssetVisibility.hidden => AssetVisibility.hidden,
|
|
api.AssetVisibility.archive => AssetVisibility.archive,
|
|
api.AssetVisibility.locked => AssetVisibility.locked,
|
|
_ => AssetVisibility.timeline,
|
|
};
|
|
}
|
|
|
|
extension on api.AssetTypeEnum {
|
|
AssetType toAssetType() => switch (this) {
|
|
api.AssetTypeEnum.IMAGE => AssetType.image,
|
|
api.AssetTypeEnum.VIDEO => AssetType.video,
|
|
api.AssetTypeEnum.AUDIO => AssetType.audio,
|
|
api.AssetTypeEnum.OTHER => AssetType.other,
|
|
_ => throw Exception('Unknown AssetType value: $this'),
|
|
};
|
|
}
|