mirror of
https://github.com/immich-app/immich.git
synced 2025-01-01 08:31:59 +00:00
69d2fcb43e
* refactor: asset media endpoints * refactor: mobile upload livePhoto as separate request * refactor: change mobile backup flow to use new asset upload endpoints * chore: format and analyze dart code * feat: mark motion as hidden when linked * feat: upload video portion of live photo before image portion * fix: incorrect assetApi calls in mobile code * fix: download asset --------- Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com> Co-authored-by: Zack Pollard <zackpollard@ymail.com>
81 lines
2.2 KiB
Dart
81 lines
2.2 KiB
Dart
import 'package:immich_mobile/entities/album.entity.dart';
|
|
import 'package:immich_mobile/entities/asset.entity.dart';
|
|
import 'package:immich_mobile/entities/store.entity.dart';
|
|
import 'package:isar/isar.dart';
|
|
import 'package:openapi/api.dart';
|
|
|
|
String getThumbnailUrl(
|
|
final Asset asset, {
|
|
AssetMediaSize type = AssetMediaSize.thumbnail,
|
|
}) {
|
|
return getThumbnailUrlForRemoteId(asset.remoteId!, type: type);
|
|
}
|
|
|
|
String getThumbnailCacheKey(
|
|
final Asset asset, {
|
|
AssetMediaSize type = AssetMediaSize.thumbnail,
|
|
}) {
|
|
return getThumbnailCacheKeyForRemoteId(asset.remoteId!, type: type);
|
|
}
|
|
|
|
String getThumbnailCacheKeyForRemoteId(
|
|
final String id, {
|
|
AssetMediaSize type = AssetMediaSize.thumbnail,
|
|
}) {
|
|
if (type == AssetMediaSize.thumbnail) {
|
|
return 'thumbnail-image-$id';
|
|
} else {
|
|
return '${id}_previewStage';
|
|
}
|
|
}
|
|
|
|
String getAlbumThumbnailUrl(
|
|
final Album album, {
|
|
AssetMediaSize type = AssetMediaSize.thumbnail,
|
|
}) {
|
|
if (album.thumbnail.value?.remoteId == null) {
|
|
return '';
|
|
}
|
|
return getThumbnailUrlForRemoteId(
|
|
album.thumbnail.value!.remoteId!,
|
|
type: type,
|
|
);
|
|
}
|
|
|
|
String getAlbumThumbNailCacheKey(
|
|
final Album album, {
|
|
AssetMediaSize type = AssetMediaSize.thumbnail,
|
|
}) {
|
|
if (album.thumbnail.value?.remoteId == null) {
|
|
return '';
|
|
}
|
|
return getThumbnailCacheKeyForRemoteId(
|
|
album.thumbnail.value!.remoteId!,
|
|
type: type,
|
|
);
|
|
}
|
|
|
|
String getImageUrl(final Asset asset) {
|
|
return getImageUrlFromId(asset.remoteId!);
|
|
}
|
|
|
|
String getImageUrlFromId(final String id) {
|
|
return '${Store.get(StoreKey.serverEndpoint)}/assets/$id/thumbnail?size=preview';
|
|
}
|
|
|
|
String getImageCacheKey(final Asset asset) {
|
|
// Assets from response DTOs do not have an isar id, querying which would give us the default autoIncrement id
|
|
final isFromDto = asset.id == Isar.autoIncrement;
|
|
return '${isFromDto ? asset.remoteId : asset.id}_fullStage';
|
|
}
|
|
|
|
String getThumbnailUrlForRemoteId(
|
|
final String id, {
|
|
AssetMediaSize type = AssetMediaSize.thumbnail,
|
|
}) {
|
|
return '${Store.get(StoreKey.serverEndpoint)}/assets/$id/thumbnail?format=${type.value}';
|
|
}
|
|
|
|
String getFaceThumbnailUrl(final String personId) {
|
|
return '${Store.get(StoreKey.serverEndpoint)}/people/$personId/thumbnail';
|
|
}
|