mirror of
https://github.com/immich-app/immich.git
synced 2024-12-25 10:43:13 +02:00
192e950567
* fix: timezone bucket timezones * chore: open api * fix: interpret local time in utc * fix: tests * fix: refactor memory lane * fix(web): use local date in memory viewer * chore: set localDateTime non-null * fix: filter out memories from the current year * wip: move localDateTime to asset * fix: correct sorting from db * fix: migration * fix: web typo * fix: formatting * fix: e2e * chore: localDateTime is non-null * chore: more non-nulliness * fix: asset stub * fix: tests * fix: use extract and index for day of year * fix: don't show memories before today * fix: cleanup * fix: tests * fix: only use localtime for tz * fix: display memories in client timezone * fix: tests * fix: svelte tests * fix: bugs * chore: open api --------- Co-authored-by: Jonathan Jogenfors <jonathan@jogenfors.se>
51 lines
1.3 KiB
Dart
51 lines
1.3 KiB
Dart
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
|
import 'package:immich_mobile/shared/models/asset.dart';
|
|
import 'package:immich_mobile/modules/memories/models/memory.dart';
|
|
import 'package:immich_mobile/shared/providers/api.provider.dart';
|
|
import 'package:immich_mobile/shared/services/api.service.dart';
|
|
import 'package:logging/logging.dart';
|
|
import 'package:openapi/api.dart';
|
|
|
|
final memoryServiceProvider = StateProvider<MemoryService>((ref) {
|
|
return MemoryService(
|
|
ref.watch(apiServiceProvider),
|
|
);
|
|
});
|
|
|
|
class MemoryService {
|
|
final log = Logger("MemoryService");
|
|
|
|
final ApiService _apiService;
|
|
|
|
MemoryService(this._apiService);
|
|
|
|
Future<List<Memory>?> getMemoryLane() async {
|
|
try {
|
|
final now = DateTime.now();
|
|
final data = await _apiService.assetApi.getMemoryLane(
|
|
now.day,
|
|
now.month,
|
|
);
|
|
|
|
if (data == null) {
|
|
return null;
|
|
}
|
|
|
|
List<Memory> memories = [];
|
|
for (final MemoryLaneResponseDto(:title, :assets) in data) {
|
|
memories.add(
|
|
Memory(
|
|
title: title,
|
|
assets: assets.map((a) => Asset.remote(a)).toList(),
|
|
),
|
|
);
|
|
}
|
|
|
|
return memories.isNotEmpty ? memories : null;
|
|
} catch (error, stack) {
|
|
log.severe("Cannot get memories ${error.toString()}", error, stack);
|
|
return null;
|
|
}
|
|
}
|
|
}
|