Browse Source

fix(mobile): setting to always display remote assets (#3044)

Fynn Petersen-Frey 2 years ago
parent
commit
615893be38

+ 3 - 1
mobile/assets/i18n/en-US.json

@@ -5,6 +5,8 @@
   "advanced_settings_tile_title": "Advanced",
   "advanced_settings_tile_title": "Advanced",
   "advanced_settings_troubleshooting_subtitle": "Enable additional features for troubleshooting",
   "advanced_settings_troubleshooting_subtitle": "Enable additional features for troubleshooting",
   "advanced_settings_troubleshooting_title": "Troubleshooting",
   "advanced_settings_troubleshooting_title": "Troubleshooting",
+  "advanced_settings_prefer_remote_title": "Prefer remote images",
+  "advanced_settings_prefer_remote_subtitle": "Some devices are painfully slow to load thumbnails from assets on the device. Activate this setting to load remote images instead.",
   "album_info_card_backup_album_excluded": "EXCLUDED",
   "album_info_card_backup_album_excluded": "EXCLUDED",
   "album_info_card_backup_album_included": "INCLUDED",
   "album_info_card_backup_album_included": "INCLUDED",
   "album_thumbnail_card_item": "1 item",
   "album_thumbnail_card_item": "1 item",
@@ -288,4 +290,4 @@
   "version_announcement_overlay_text_3": " and ensure your docker-compose and .env setup is up-to-date to prevent any misconfigurations, especially if you use WatchTower or any mechanism that handles updating your server application automatically.",
   "version_announcement_overlay_text_3": " and ensure your docker-compose and .env setup is up-to-date to prevent any misconfigurations, especially if you use WatchTower or any mechanism that handles updating your server application automatically.",
   "version_announcement_overlay_title": "New Server Version Available \uD83C\uDF89",
   "version_announcement_overlay_title": "New Server Version Available \uD83C\uDF89",
   "all_people_page_title": "People"
   "all_people_page_title": "People"
-}
+}

+ 7 - 3
mobile/lib/modules/asset_viewer/views/gallery_viewer.dart

@@ -131,7 +131,8 @@ class GalleryViewerPage extends HookConsumerWidget {
       if (index < totalAssets && index >= 0) {
       if (index < totalAssets && index >= 0) {
         final asset = loadAsset(index);
         final asset = loadAsset(index);
 
 
-        if (asset.isLocal) {
+        if (!asset.isRemote ||
+            asset.isLocal && !Store.get(StoreKey.preferRemoteImage, false)) {
           // Preload the local asset
           // Preload the local asset
           precacheImage(localImageProvider(asset), context);
           precacheImage(localImageProvider(asset), context);
         } else {
         } else {
@@ -459,7 +460,8 @@ class GalleryViewerPage extends HookConsumerWidget {
     });
     });
 
 
     ImageProvider imageProvider(Asset asset) {
     ImageProvider imageProvider(Asset asset) {
-      if (asset.isLocal) {
+      if (!asset.isRemote ||
+          asset.isLocal && !Store.get(StoreKey.preferRemoteImage, false)) {
         return localImageProvider(asset);
         return localImageProvider(asset);
       } else {
       } else {
         if (isLoadOriginal.value) {
         if (isLoadOriginal.value) {
@@ -518,7 +520,9 @@ class GalleryViewerPage extends HookConsumerWidget {
               loadingBuilder: isLoadPreview.value
               loadingBuilder: isLoadPreview.value
                   ? (context, event) {
                   ? (context, event) {
                       final a = asset();
                       final a = asset();
-                      if (!a.isLocal) {
+                      if (!a.isLocal ||
+                          (a.isRemote &&
+                              Store.get(StoreKey.preferRemoteImage, false))) {
                         // Use the WEBP Thumbnail as a placeholder for the JPEG thumbnail to achieve
                         // Use the WEBP Thumbnail as a placeholder for the JPEG thumbnail to achieve
                         // Three-Stage Loading (WEBP -> JPEG -> Original)
                         // Three-Stage Loading (WEBP -> JPEG -> Original)
                         final webPThumbnail = CachedNetworkImage(
                         final webPThumbnail = CachedNetworkImage(

+ 2 - 1
mobile/lib/modules/settings/services/app_settings.service.dart

@@ -44,7 +44,8 @@ enum AppSettingsEnum<T> {
     0,
     0,
   ),
   ),
   advancedTroubleshooting<bool>(StoreKey.advancedTroubleshooting, null, false),
   advancedTroubleshooting<bool>(StoreKey.advancedTroubleshooting, null, false),
-  logLevel<int>(StoreKey.logLevel, null, 5) // Level.INFO = 5
+  logLevel<int>(StoreKey.logLevel, null, 5), // Level.INFO = 5
+  preferRemoteImage<bool>(StoreKey.preferRemoteImage, null, false),
   ;
   ;
 
 
   const AppSettingsEnum(this.storeKey, this.hiveKey, this.defaultValue);
   const AppSettingsEnum(this.storeKey, this.hiveKey, this.defaultValue);

+ 11 - 0
mobile/lib/modules/settings/ui/advanced_settings/advanced_settings.dart

@@ -16,6 +16,8 @@ class AdvancedSettings extends HookConsumerWidget {
     final isEnabled =
     final isEnabled =
         useState(AppSettingsEnum.advancedTroubleshooting.defaultValue);
         useState(AppSettingsEnum.advancedTroubleshooting.defaultValue);
     final levelId = useState(AppSettingsEnum.logLevel.defaultValue);
     final levelId = useState(AppSettingsEnum.logLevel.defaultValue);
+    final preferRemote =
+        useState(AppSettingsEnum.preferRemoteImage.defaultValue);
 
 
     useEffect(
     useEffect(
       () {
       () {
@@ -23,6 +25,8 @@ class AdvancedSettings extends HookConsumerWidget {
           AppSettingsEnum.advancedTroubleshooting,
           AppSettingsEnum.advancedTroubleshooting,
         );
         );
         levelId.value = appSettingService.getSetting(AppSettingsEnum.logLevel);
         levelId.value = appSettingService.getSetting(AppSettingsEnum.logLevel);
+        preferRemote.value =
+            appSettingService.getSetting(AppSettingsEnum.preferRemoteImage);
         return null;
         return null;
       },
       },
       [],
       [],
@@ -77,6 +81,13 @@ class AdvancedSettings extends HookConsumerWidget {
             activeColor: Theme.of(context).primaryColor,
             activeColor: Theme.of(context).primaryColor,
           ),
           ),
         ),
         ),
+        SettingsSwitchListTile(
+          appSettingService: appSettingService,
+          valueNotifier: preferRemote,
+          settingsEnum: AppSettingsEnum.preferRemoteImage,
+          title: "advanced_settings_prefer_remote_title".tr(),
+          subtitle: "advanced_settings_prefer_remote_subtitle".tr(),
+        ),
       ],
       ],
     );
     );
   }
   }

+ 1 - 0
mobile/lib/shared/models/store.dart

@@ -173,6 +173,7 @@ enum StoreKey<T> {
   selectedAlbumSortOrder<int>(113, type: int),
   selectedAlbumSortOrder<int>(113, type: int),
   advancedTroubleshooting<bool>(114, type: bool),
   advancedTroubleshooting<bool>(114, type: bool),
   logLevel<int>(115, type: int),
   logLevel<int>(115, type: int),
+  preferRemoteImage<bool>(116, type: bool),
   ;
   ;
 
 
   const StoreKey(
   const StoreKey(

+ 2 - 1
mobile/lib/shared/ui/immich_image.dart

@@ -43,7 +43,8 @@ class ImmichImage extends StatelessWidget {
       );
       );
     }
     }
     final Asset asset = this.asset!;
     final Asset asset = this.asset!;
-    if (asset.isLocal) {
+    if (!asset.isRemote ||
+        (asset.isLocal && !Store.get(StoreKey.preferRemoteImage, false))) {
       return Image(
       return Image(
         image: AssetEntityImageProvider(
         image: AssetEntityImageProvider(
           asset.local!,
           asset.local!,