mirror of
https://github.com/KevinMidboe/immich.git
synced 2025-10-29 17:40:28 +00:00
refactor(mobile): reworked Asset, store all required fields from local & remote (#1539)
replace usage of AssetResponseDto with Asset Add new class ExifInfo to store data from ExifResponseDto
This commit is contained in:
committed by
GitHub
parent
7bd2455175
commit
0048662182
@@ -45,9 +45,11 @@ class SearchResultPageState {
|
||||
isLoading: map['isLoading'] ?? false,
|
||||
isSuccess: map['isSuccess'] ?? false,
|
||||
isError: map['isError'] ?? false,
|
||||
searchResult: List<Asset>.from(
|
||||
searchResult: List.from(
|
||||
map['searchResult']
|
||||
?.map((x) => Asset.remote(AssetResponseDto.fromJson(x))),
|
||||
.map(AssetResponseDto.fromJson)
|
||||
.where((e) => e != null)
|
||||
.map(Asset.remote),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -30,9 +30,7 @@ class SearchResultPageNotifier extends StateNotifier<SearchResultPageState> {
|
||||
isSuccess: false,
|
||||
);
|
||||
|
||||
List<Asset>? assets = (await _searchService.searchAsset(searchTerm))
|
||||
?.map((e) => Asset.remote(e))
|
||||
.toList();
|
||||
List<Asset>? assets = await _searchService.searchAsset(searchTerm);
|
||||
|
||||
if (assets != null) {
|
||||
state = state.copyWith(
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:immich_mobile/shared/models/asset.dart';
|
||||
import 'package:immich_mobile/shared/providers/api.provider.dart';
|
||||
import 'package:immich_mobile/shared/services/api.service.dart';
|
||||
import 'package:openapi/api.dart';
|
||||
@@ -24,10 +25,14 @@ class SearchService {
|
||||
}
|
||||
}
|
||||
|
||||
Future<List<AssetResponseDto>?> searchAsset(String searchTerm) async {
|
||||
Future<List<Asset>?> searchAsset(String searchTerm) async {
|
||||
try {
|
||||
return await _apiService.assetApi
|
||||
final List<AssetResponseDto>? results = await _apiService.assetApi
|
||||
.searchAsset(SearchAssetDto(searchTerm: searchTerm));
|
||||
if (results == null) {
|
||||
return null;
|
||||
}
|
||||
return results.map((e) => Asset.remote(e)).toList();
|
||||
} catch (e) {
|
||||
debugPrint("[ERROR] [searchAsset] ${e.toString()}");
|
||||
return null;
|
||||
@@ -50,7 +55,7 @@ class SearchService {
|
||||
return await _apiService.assetApi.getCuratedObjects();
|
||||
} catch (e) {
|
||||
debugPrint("Error [getCuratedObjects] ${e.toString()}");
|
||||
throw [];
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user