mirror of
https://github.com/openfoodfacts/smooth-app.git
synced 2025-08-06 18:25:11 +08:00

Deleted file: * `background_task_helper.dart` New files: * `background_task_manager.dart`: Management of background tasks: single thread, block, restart, display. * `dao_instant_string.dart`: Where we store strings that need INSTANT access (= not lazy, no await). Impacted fles: * `abstract_background_task.dart`: refactored * `background_task_details.dart`: refactored around the changes in `AbstractBackgroundTask` * `background_task_image.dart`: refactored around the changes in `AbstractBackgroundTask` * `dao_string_list.dart`: refactoring around now managing several lists; removed unnecessary `await` for a non-lazy dao * `local_database.dart`: added the new class `DaoInstantString`; relaunch the background task manager at every refresh * `main.dart`: minor refactoring * `new_crop_page.dart`: unrelated bug fix * `offline_tasks_page.dart`: refactored around the new `BackgroundTaskManager` * `operation_type.dart`: added helper methods * `product_image_gallery_view.dart`: minor refactoring * `product_image_viewer.dart`: unrelated bug fix - the product was not refreshed, and so wasn't the image even after a successful download * `pubspec.lock`: wtf * `pubspec.yaml`: removed `flutter_task_manager` * `search_history_view.dart`: minor refactoring now that we have several lists in `DaoStringList` * `search_page.dart`: minor refactoring now that we have several lists in `DaoStringList` * `up_to_date_changes.dart`: minor refactoring * `up_to_date_product_provider.dart`: minor refactoring
24 lines
798 B
Dart
24 lines
798 B
Dart
import 'package:hive_flutter/hive_flutter.dart';
|
|
import 'package:smooth_app/database/abstract_dao.dart';
|
|
import 'package:smooth_app/database/local_database.dart';
|
|
|
|
/// Where we store strings that need INSTANT access (= not lazy, no await).
|
|
class DaoInstantString extends AbstractDao {
|
|
DaoInstantString(final LocalDatabase localDatabase) : super(localDatabase);
|
|
|
|
static const String _hiveBoxName = 'instantString';
|
|
|
|
@override
|
|
Future<void> init() async => Hive.openBox<String>(_hiveBoxName);
|
|
|
|
@override
|
|
void registerAdapter() {}
|
|
|
|
Box<String> _getBox() => Hive.box<String>(_hiveBoxName);
|
|
|
|
String? get(final String key) => _getBox().get(key);
|
|
|
|
Future<void> put(final String key, final String? value) async =>
|
|
value == null ? _getBox().delete(key) : _getBox().put(key, value);
|
|
}
|