mirror of
https://github.com/immich-app/immich.git
synced 2026-10-29 13:15:45 +01:00
* chore(mobile): migrate OCR, Tag, and UserMetadata to Store * Add comments to Tag HTTP repository * Add mounted check
49 lines
2.0 KiB
Dart
49 lines
2.0 KiB
Dart
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
|
import 'package:immich_mobile/data/data_controller.dart';
|
|
import 'package:immich_mobile/data/db/main/database.dart';
|
|
import 'package:immich_mobile/data/store/activity.dart';
|
|
import 'package:immich_mobile/data/store/ocr.dart';
|
|
import 'package:immich_mobile/data/store/person.dart';
|
|
import 'package:immich_mobile/data/store/tag.dart';
|
|
import 'package:immich_mobile/data/store/user_metadata.dart';
|
|
import 'package:immich_mobile/services/api.service.dart';
|
|
|
|
/// The [DataController] backing this container's store
|
|
///
|
|
/// Must be overridden with a constructed instance (`Store.overrideWithValue`)
|
|
final _dataControllerProvider = Provider<DataController>(
|
|
(ref) => throw UnimplementedError("DataController instance must be set via Store.overrideWith"),
|
|
);
|
|
|
|
final _apiServiceProvider = Provider<ApiService>(
|
|
(ref) => throw UnimplementedError("ApiService instance must be set via Store.overrideWith"),
|
|
);
|
|
|
|
/// Global data layer, providing access to Drift and HTTP APIs, scoped by entity
|
|
abstract final class Store {
|
|
static List<Override> overrideWith({required DataController dataController, required ApiService apiService}) => [
|
|
_dataControllerProvider.overrideWithValue(dataController),
|
|
_apiServiceProvider.overrideWithValue(apiService),
|
|
];
|
|
|
|
/// Direct database access for the repositories that have not yet been migrated to `Store`
|
|
// TODO(rewrite): Remove this provider once all repositories have migrated to `Store`
|
|
static final db = Provider<Drift>((ref) => ref.watch(_dataControllerProvider).db);
|
|
|
|
/// Direct API access for the repositories that have not yet been migrated to `Store`
|
|
// TODO(rewrite): Remove this provider once all repositories have migrated to `Store`
|
|
static final api = Provider<ApiService>((ref) => ref.watch(_apiServiceProvider));
|
|
|
|
// ----
|
|
|
|
static final people = PersonStore.instance;
|
|
|
|
static final activity = ActivityStore.instance;
|
|
|
|
static final ocr = OcrStore.instance;
|
|
|
|
static final tags = TagStore.instance;
|
|
|
|
static final userMetadata = UserMetadataStore.instance;
|
|
}
|