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:
Fynn Petersen-Frey 2023-02-04 21:42:42 +01:00 committed by GitHub
parent 7bd2455175
commit 0048662182
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
28 changed files with 626 additions and 504 deletions

View file

@ -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),
),
);
}

View file

@ -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(

View file

@ -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 [];
}
}
}