mirror of
https://github.com/immich-app/immich.git
synced 2025-05-24 01:12:58 -04:00
* refactor: user entity * fix: add users to album & user profile url * chore: rebase fixes * generate files * fix(mobile): timeline not reset on login * fix: test stub * refactor: rename user model (#16813) * refactor: rename user model * simplify import --------- Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com> Co-authored-by: Alex <alex.tran1502@gmail.com> * chore: generate files * fix: use getAllAccessible instead of getAll --------- Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com> Co-authored-by: Alex <alex.tran1502@gmail.com>
68 lines
2.1 KiB
Dart
68 lines
2.1 KiB
Dart
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
|
import 'package:immich_mobile/infrastructure/utils/user.converter.dart';
|
|
import 'package:immich_mobile/interfaces/activity_api.interface.dart';
|
|
import 'package:immich_mobile/models/activities/activity.model.dart';
|
|
import 'package:immich_mobile/providers/api.provider.dart';
|
|
import 'package:immich_mobile/repositories/api.repository.dart';
|
|
import 'package:openapi/api.dart';
|
|
|
|
final activityApiRepositoryProvider = Provider(
|
|
(ref) => ActivityApiRepository(ref.watch(apiServiceProvider).activitiesApi),
|
|
);
|
|
|
|
class ActivityApiRepository extends ApiRepository
|
|
implements IActivityApiRepository {
|
|
final ActivitiesApi _api;
|
|
|
|
ActivityApiRepository(this._api);
|
|
|
|
@override
|
|
Future<List<Activity>> getAll(String albumId, {String? assetId}) async {
|
|
final response =
|
|
await checkNull(_api.getActivities(albumId, assetId: assetId));
|
|
return response.map(_toActivity).toList();
|
|
}
|
|
|
|
@override
|
|
Future<Activity> create(
|
|
String albumId,
|
|
ActivityType type, {
|
|
String? assetId,
|
|
String? comment,
|
|
}) async {
|
|
final dto = ActivityCreateDto(
|
|
albumId: albumId,
|
|
type: type == ActivityType.comment
|
|
? ReactionType.comment
|
|
: ReactionType.like,
|
|
assetId: assetId,
|
|
comment: comment,
|
|
);
|
|
final response = await checkNull(_api.createActivity(dto));
|
|
return _toActivity(response);
|
|
}
|
|
|
|
@override
|
|
Future<void> delete(String id) {
|
|
return checkNull(_api.deleteActivity(id));
|
|
}
|
|
|
|
@override
|
|
Future<ActivityStats> getStats(String albumId, {String? assetId}) async {
|
|
final response =
|
|
await checkNull(_api.getActivityStatistics(albumId, assetId: assetId));
|
|
return ActivityStats(comments: response.comments);
|
|
}
|
|
|
|
static Activity _toActivity(ActivityResponseDto dto) => Activity(
|
|
id: dto.id,
|
|
createdAt: dto.createdAt,
|
|
type: dto.type == ReactionType.comment
|
|
? ActivityType.comment
|
|
: ActivityType.like,
|
|
user: UserConverter.fromSimpleUserDto(dto.user),
|
|
assetId: dto.assetId,
|
|
comment: dto.comment,
|
|
);
|
|
}
|