mirror of
				https://github.com/KevinMidboe/immich.git
				synced 2025-10-29 17:40:28 +00:00 
			
		
		
		
	* feature(mobile): sync assets, albums & users to local database on device * try to fix tests * move DB sync operations to new SyncService * clear db on user logout * fix reason for endless loading timeline * fix error when deleting album * fix thumbnail of device albums * add a few comments * fix Hive box not open in album service when loading local assets * adjust tests to int IDs * fix bug: show all albums when Recent is selected * update generated api * reworked Recents album isAll handling * guard against wrongly interleaved sync operations * fix: timeline asset ordering (sort asset state by created at) * fix: sort assets in albums by created at
		
			
				
	
	
		
			67 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			Dart
		
	
	
	
	
	
			
		
		
	
	
			67 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			Dart
		
	
	
	
	
	
| import 'package:hive/hive.dart';
 | |
| import 'package:immich_mobile/shared/models/album.dart';
 | |
| import 'package:immich_mobile/shared/models/asset.dart';
 | |
| import 'package:openapi/api.dart';
 | |
| 
 | |
| import '../constants/hive_box.dart';
 | |
| 
 | |
| String getThumbnailUrl(
 | |
|   final Asset asset, {
 | |
|   ThumbnailFormat type = ThumbnailFormat.WEBP,
 | |
| }) {
 | |
|   return _getThumbnailUrl(asset.remoteId!, type: type);
 | |
| }
 | |
| 
 | |
| String getThumbnailCacheKey(
 | |
|   final Asset asset, {
 | |
|   ThumbnailFormat type = ThumbnailFormat.WEBP,
 | |
| }) {
 | |
|   return _getThumbnailCacheKey(asset.remoteId!, type);
 | |
| }
 | |
| 
 | |
| String _getThumbnailCacheKey(final String id, final ThumbnailFormat type) {
 | |
|   if (type == ThumbnailFormat.WEBP) {
 | |
|     return 'thumbnail-image-$id';
 | |
|   } else {
 | |
|     return '${id}_previewStage';
 | |
|   }
 | |
| }
 | |
| 
 | |
| String getAlbumThumbnailUrl(
 | |
|   final Album album, {
 | |
|   ThumbnailFormat type = ThumbnailFormat.WEBP,
 | |
| }) {
 | |
|   if (album.thumbnail.value?.remoteId == null) {
 | |
|     return '';
 | |
|   }
 | |
|   return _getThumbnailUrl(album.thumbnail.value!.remoteId!, type: type);
 | |
| }
 | |
| 
 | |
| String getAlbumThumbNailCacheKey(
 | |
|   final Album album, {
 | |
|   ThumbnailFormat type = ThumbnailFormat.WEBP,
 | |
| }) {
 | |
|   if (album.thumbnail.value?.remoteId == null) {
 | |
|     return '';
 | |
|   }
 | |
|   return _getThumbnailCacheKey(album.thumbnail.value!.remoteId!, type);
 | |
| }
 | |
| 
 | |
| String getImageUrl(final Asset asset) {
 | |
|   final box = Hive.box(userInfoBox);
 | |
|   return '${box.get(serverEndpointKey)}/asset/file/${asset.remoteId}?isThumb=false';
 | |
| }
 | |
| 
 | |
| String getImageCacheKey(final Asset asset) {
 | |
|   return '${asset.id}_fullStage';
 | |
| }
 | |
| 
 | |
| String _getThumbnailUrl(
 | |
|   final String id, {
 | |
|   ThumbnailFormat type = ThumbnailFormat.WEBP,
 | |
| }) {
 | |
|   final box = Hive.box(userInfoBox);
 | |
| 
 | |
|   return '${box.get(serverEndpointKey)}/asset/thumbnail/$id?format=${type.value}';
 | |
| }
 |