mirror of
https://github.com/immich-app/immich.git
synced 2025-09-29 15:31:13 -04:00
* feat(mobile): shared album activities * add like buttons and fix behavior of unliking * fix: conditionally show activity button and fix title truncations * fix(mobile): newest/oldest album sort (#20743) * fix(mobile): newest/oldest album sort * chore: use sqlite to determine album asset timestamps * Fix missing future Co-authored-by: Alex <alex.tran1502@gmail.com> * fix: async handling of sort * chore: tests * chore: code review changes * fix: use created at for newest asset * fix: use localDateTime for sorting * chore: cleanup * chore: use final * feat: loading indicator --------- Co-authored-by: Alex <alex.tran1502@gmail.com> --------- Co-authored-by: Alex <alex.tran1502@gmail.com>
53 lines
1.7 KiB
Dart
53 lines
1.7 KiB
Dart
import 'package:immich_mobile/constants/errors.dart';
|
|
import 'package:immich_mobile/mixins/error_logger.mixin.dart';
|
|
import 'package:immich_mobile/models/activities/activity.model.dart';
|
|
import 'package:immich_mobile/repositories/activity_api.repository.dart';
|
|
import 'package:logging/logging.dart';
|
|
|
|
class ActivityService with ErrorLoggerMixin {
|
|
final ActivityApiRepository _activityApiRepository;
|
|
|
|
@override
|
|
final Logger logger = Logger("ActivityService");
|
|
|
|
ActivityService(this._activityApiRepository);
|
|
|
|
Future<List<Activity>> getAllActivities(String albumId, {String? assetId}) async {
|
|
return logError(
|
|
() => _activityApiRepository.getAll(albumId, assetId: assetId),
|
|
defaultValue: [],
|
|
errorMessage: "Failed to get all activities for album $albumId",
|
|
);
|
|
}
|
|
|
|
Future<ActivityStats> getStatistics(String albumId, {String? assetId}) async {
|
|
return logError(
|
|
() => _activityApiRepository.getStats(albumId, assetId: assetId),
|
|
defaultValue: const ActivityStats(comments: 0),
|
|
errorMessage: "Failed to statistics for album $albumId",
|
|
);
|
|
}
|
|
|
|
Future<bool> removeActivity(String id) async {
|
|
return logError(
|
|
() async {
|
|
try {
|
|
await _activityApiRepository.delete(id);
|
|
} on NoResponseDtoError {
|
|
return true;
|
|
}
|
|
return true;
|
|
},
|
|
defaultValue: false,
|
|
errorMessage: "Failed to delete activity",
|
|
);
|
|
}
|
|
|
|
AsyncFuture<Activity> addActivity(String albumId, ActivityType type, {String? assetId, String? comment}) async {
|
|
return guardError(
|
|
() => _activityApiRepository.create(albumId, type, assetId: assetId, comment: comment),
|
|
errorMessage: "Failed to create $type for album $albumId",
|
|
);
|
|
}
|
|
}
|