mirror of
https://github.com/immich-app/immich.git
synced 2025-05-30 19:54:52 -04:00
feat(mobile): use memories api (#16329)
This commit is contained in:
parent
90f7c3d9ae
commit
8ecc67a364
@ -31,6 +31,7 @@ class ApiService implements Authentication {
|
|||||||
late DownloadApi downloadApi;
|
late DownloadApi downloadApi;
|
||||||
late TrashApi trashApi;
|
late TrashApi trashApi;
|
||||||
late StacksApi stacksApi;
|
late StacksApi stacksApi;
|
||||||
|
late MemoriesApi memoriesApi;
|
||||||
|
|
||||||
ApiService() {
|
ApiService() {
|
||||||
final endpoint = Store.tryGet(StoreKey.serverEndpoint);
|
final endpoint = Store.tryGet(StoreKey.serverEndpoint);
|
||||||
@ -63,6 +64,7 @@ class ApiService implements Authentication {
|
|||||||
downloadApi = DownloadApi(_apiClient);
|
downloadApi = DownloadApi(_apiClient);
|
||||||
trashApi = TrashApi(_apiClient);
|
trashApi = TrashApi(_apiClient);
|
||||||
stacksApi = StacksApi(_apiClient);
|
stacksApi = StacksApi(_apiClient);
|
||||||
|
memoriesApi = MemoriesApi(_apiClient);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<String> resolveAndSetEndpoint(String serverUrl) async {
|
Future<String> resolveAndSetEndpoint(String serverUrl) async {
|
||||||
|
@ -6,7 +6,6 @@ import 'package:immich_mobile/providers/api.provider.dart';
|
|||||||
import 'package:immich_mobile/repositories/asset.repository.dart';
|
import 'package:immich_mobile/repositories/asset.repository.dart';
|
||||||
import 'package:immich_mobile/services/api.service.dart';
|
import 'package:immich_mobile/services/api.service.dart';
|
||||||
import 'package:logging/logging.dart';
|
import 'package:logging/logging.dart';
|
||||||
import 'package:openapi/api.dart';
|
|
||||||
|
|
||||||
final memoryServiceProvider = StateProvider<MemoryService>((ref) {
|
final memoryServiceProvider = StateProvider<MemoryService>((ref) {
|
||||||
return MemoryService(
|
return MemoryService(
|
||||||
@ -26,9 +25,8 @@ class MemoryService {
|
|||||||
Future<List<Memory>?> getMemoryLane() async {
|
Future<List<Memory>?> getMemoryLane() async {
|
||||||
try {
|
try {
|
||||||
final now = DateTime.now();
|
final now = DateTime.now();
|
||||||
final data = await _apiService.assetsApi.getMemoryLane(
|
final data = await _apiService.memoriesApi.searchMemories(
|
||||||
now.day,
|
for_: now,
|
||||||
now.month,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
if (data == null) {
|
if (data == null) {
|
||||||
@ -36,9 +34,11 @@ class MemoryService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
List<Memory> memories = [];
|
List<Memory> memories = [];
|
||||||
for (final MemoryLaneResponseDto(:yearsAgo, :assets) in data) {
|
|
||||||
final dbAssets =
|
for (final memory in data) {
|
||||||
await _assetRepository.getAllByRemoteId(assets.map((e) => e.id));
|
final dbAssets = await _assetRepository
|
||||||
|
.getAllByRemoteId(memory.assets.map((e) => e.id));
|
||||||
|
final yearsAgo = now.year - memory.data.year;
|
||||||
if (dbAssets.isNotEmpty) {
|
if (dbAssets.isNotEmpty) {
|
||||||
final String title = yearsAgo <= 1
|
final String title = yearsAgo <= 1
|
||||||
? 'memories_year_ago'.tr()
|
? 'memories_year_ago'.tr()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user