1
0
mirror of https://github.com/immich-app/immich.git synced 2024-11-24 08:52:28 +02:00

fix(mobile): load original (#11786)

* fix(mobile): load original

* revert change to format
This commit is contained in:
Alex 2024-08-14 14:52:19 -05:00 committed by GitHub
parent 9e21f254cd
commit 7d888106ed
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 17 additions and 15 deletions

View File

@ -55,8 +55,6 @@ class GalleryViewerPage extends HookConsumerWidget {
final settings = ref.watch(appSettingsServiceProvider); final settings = ref.watch(appSettingsServiceProvider);
final loadAsset = renderList.loadAsset; final loadAsset = renderList.loadAsset;
final totalAssets = useState(renderList.totalAssets); final totalAssets = useState(renderList.totalAssets);
final isLoadPreview = useState(AppSettingsEnum.loadPreview.defaultValue);
final isLoadOriginal = useState(AppSettingsEnum.loadOriginal.defaultValue);
final shouldLoopVideo = useState(AppSettingsEnum.loopVideo.defaultValue); final shouldLoopVideo = useState(AppSettingsEnum.loopVideo.defaultValue);
final isZoomed = useState(false); final isZoomed = useState(false);
final isPlayingVideo = useState(false); final isPlayingVideo = useState(false);
@ -97,10 +95,6 @@ class GalleryViewerPage extends HookConsumerWidget {
useEffect( useEffect(
() { () {
isLoadPreview.value =
settings.getSetting<bool>(AppSettingsEnum.loadPreview);
isLoadOriginal.value =
settings.getSetting<bool>(AppSettingsEnum.loadOriginal);
shouldLoopVideo.value = shouldLoopVideo.value =
settings.getSetting<bool>(AppSettingsEnum.loopVideo); settings.getSetting<bool>(AppSettingsEnum.loopVideo);
return null; return null;
@ -324,6 +318,7 @@ class GalleryViewerPage extends HookConsumerWidget {
builder: (context, index) { builder: (context, index) {
final a = final a =
index == currentIndex.value ? asset : loadAsset(index); index == currentIndex.value ? asset : loadAsset(index);
final ImageProvider provider = final ImageProvider provider =
ImmichImage.imageProvider(asset: a); ImmichImage.imageProvider(asset: a);

View File

@ -7,6 +7,8 @@ import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/painting.dart'; import 'package:flutter/painting.dart';
import 'package:immich_mobile/entities/asset.entity.dart'; import 'package:immich_mobile/entities/asset.entity.dart';
import 'package:immich_mobile/entities/store.entity.dart';
import 'package:immich_mobile/services/app_settings.service.dart';
import 'package:photo_manager/photo_manager.dart'; import 'package:photo_manager/photo_manager.dart';
/// The local image provider for an asset /// The local image provider for an asset
@ -17,6 +19,12 @@ class ImmichLocalImageProvider extends ImageProvider<ImmichLocalImageProvider> {
required this.asset, required this.asset,
}) : assert(asset.local != null, 'Only usable when asset.local is set'); }) : assert(asset.local != null, 'Only usable when asset.local is set');
/// Whether to show the original file or load a compressed version
bool get _useOriginal => Store.get(
AppSettingsEnum.loadOriginal.storeKey,
AppSettingsEnum.loadOriginal.defaultValue,
);
/// Converts an [ImageProvider]'s settings plus an [ImageConfiguration] to a key /// Converts an [ImageProvider]'s settings plus an [ImageConfiguration] to a key
/// that describes the precise image to load. /// that describes the precise image to load.
@override @override
@ -62,8 +70,11 @@ class ImmichLocalImageProvider extends ImageProvider<ImmichLocalImageProvider> {
if (asset.isImage) { if (asset.isImage) {
/// Using 2K thumbnail for local iOS image to avoid double swiping issue /// Using 2K thumbnail for local iOS image to avoid double swiping issue
if (Platform.isIOS) { if (Platform.isIOS) {
final largeImageBytes = await asset.local final largeImageBytes = _useOriginal
?.thumbnailDataWithSize(const ThumbnailSize(3840, 2160)); ? await asset.local?.originBytes
: await asset.local
?.thumbnailDataWithSize(const ThumbnailSize(3840, 2160));
if (largeImageBytes == null) { if (largeImageBytes == null) {
throw StateError( throw StateError(
"Loading thumb for local photo ${asset.fileName} failed", "Loading thumb for local photo ${asset.fileName} failed",

View File

@ -101,7 +101,7 @@ class ImmichRemoteImageProvider
// Load the final remote image // Load the final remote image
if (_useOriginal) { if (_useOriginal) {
// Load the original image // Load the original image
final url = getImageUrlFromId(key.assetId); final url = getOriginalUrlForRemoteId(key.assetId);
final codec = await ImageLoader.loadImageFromCache( final codec = await ImageLoader.loadImageFromCache(
url, url,
cache: cache, cache: cache,

View File

@ -55,12 +55,8 @@ String getAlbumThumbNailCacheKey(
); );
} }
String getImageUrl(final Asset asset) { String getOriginalUrlForRemoteId(final String id) {
return getImageUrlFromId(asset.remoteId!); return '${Store.get(StoreKey.serverEndpoint)}/assets/$id/original';
}
String getImageUrlFromId(final String id) {
return '${Store.get(StoreKey.serverEndpoint)}/assets/$id/thumbnail?size=preview';
} }
String getImageCacheKey(final Asset asset) { String getImageCacheKey(final Asset asset) {