From ef67d414fdfc7a3521109892955b308d99da2378 Mon Sep 17 00:00:00 2001 From: Ming Ming Date: Sat, 23 Nov 2024 23:04:13 +0800 Subject: [PATCH] Rename exif pref --- app/lib/controller/metadata_controller.dart | 12 ++++++------ app/lib/controller/pref_controller.dart | 10 +++++----- app/lib/controller/pref_controller.g.dart | 12 +++++++----- app/lib/controller/pref_controller/util.dart | 3 +++ app/lib/widget/settings/metadata/bloc.dart | 6 +++--- 5 files changed, 24 insertions(+), 19 deletions(-) diff --git a/app/lib/controller/metadata_controller.dart b/app/lib/controller/metadata_controller.dart index 581461a8..24e55336 100644 --- a/app/lib/controller/metadata_controller.dart +++ b/app/lib/controller/metadata_controller.dart @@ -18,8 +18,8 @@ class MetadataController { required this.account, required this.prefController, }) { - _subscriptions - .add(prefController.isEnableExifChange.listen(_onSetEnableExif)); + _subscriptions.add( + prefController.isEnableClientExifChange.listen(_onSetEnableClientExif)); } void dispose() { @@ -44,16 +44,16 @@ class MetadataController { void kickstart() { _log.info("[kickstart] Metadata controller enabled"); _isEnable = true; - if (prefController.isEnableExifValue && !_hasStarted) { + if (prefController.isEnableClientExifValue && !_hasStarted) { _startMetadataTask(); } } - void _onSetEnableExif(bool value) { - _log.info("[_onSetEnableExif]"); + void _onSetEnableClientExif(bool value) { + _log.info("[_onSetEnableClientExif]"); if (value) { if (!_isEnable) { - _log.info("[_onSetEnableExif] Ignored as not enabled"); + _log.info("[_onSetEnableClientExif] Ignored as not enabled"); return; } _startMetadataTask(); diff --git a/app/lib/controller/pref_controller.dart b/app/lib/controller/pref_controller.dart index a807f949..2f7536d9 100644 --- a/app/lib/controller/pref_controller.dart +++ b/app/lib/controller/pref_controller.dart @@ -69,9 +69,9 @@ class PrefController { value: value, ); - Future setEnableExif(bool value) => _set( - controller: _isEnableExifController, - setter: (pref, value) => pref.setEnableExif(value), + Future setEnableClientExif(bool value) => _set( + controller: _isEnableClientExifController, + setter: (pref, value) => pref.setEnableClientExif(value), value: value, ); @@ -331,8 +331,8 @@ class PrefController { late final _homeAlbumsSortController = BehaviorSubject.seeded( CollectionSort.values[pref.getHomeAlbumsSortOr(0)]); @npSubjectAccessor - late final _isEnableExifController = - BehaviorSubject.seeded(pref.isEnableExifOr(true)); + late final _isEnableClientExifController = + BehaviorSubject.seeded(pref.isEnableClientExif() ?? true); @npSubjectAccessor late final _shouldProcessExifWifiOnlyController = BehaviorSubject.seeded(pref.shouldProcessExifWifiOnlyOr(true)); diff --git a/app/lib/controller/pref_controller.g.dart b/app/lib/controller/pref_controller.g.dart index f2e92c47..5da6d873 100644 --- a/app/lib/controller/pref_controller.g.dart +++ b/app/lib/controller/pref_controller.g.dart @@ -56,11 +56,13 @@ extension $PrefControllerNpSubjectAccessor on PrefController { Stream get homeAlbumsSortChange => homeAlbumsSort.distinct().skip(1); CollectionSort get homeAlbumsSortValue => _homeAlbumsSortController.value; -// _isEnableExifController - ValueStream get isEnableExif => _isEnableExifController.stream; - Stream get isEnableExifNew => isEnableExif.skip(1); - Stream get isEnableExifChange => isEnableExif.distinct().skip(1); - bool get isEnableExifValue => _isEnableExifController.value; +// _isEnableClientExifController + ValueStream get isEnableClientExif => + _isEnableClientExifController.stream; + Stream get isEnableClientExifNew => isEnableClientExif.skip(1); + Stream get isEnableClientExifChange => + isEnableClientExif.distinct().skip(1); + bool get isEnableClientExifValue => _isEnableClientExifController.value; // _shouldProcessExifWifiOnlyController ValueStream get shouldProcessExifWifiOnly => _shouldProcessExifWifiOnlyController.stream; diff --git a/app/lib/controller/pref_controller/util.dart b/app/lib/controller/pref_controller/util.dart index ad3c6f2e..f59d2c85 100644 --- a/app/lib/controller/pref_controller/util.dart +++ b/app/lib/controller/pref_controller/util.dart @@ -15,6 +15,9 @@ extension on Pref { Future setHomeAlbumsSort(int value) => provider.setInt(PrefKey.homeAlbumsSort, value); + bool? isEnableClientExif() => isEnableExif(); + Future setEnableClientExif(bool value) => setEnableExif(value); + bool? isDarkTheme() => provider.getBool(PrefKey.darkTheme); bool isDarkThemeOr(bool def) => isDarkTheme() ?? def; Future setDarkTheme(bool value) => diff --git a/app/lib/widget/settings/metadata/bloc.dart b/app/lib/widget/settings/metadata/bloc.dart index bed6ea50..c07ec967 100644 --- a/app/lib/widget/settings/metadata/bloc.dart +++ b/app/lib/widget/settings/metadata/bloc.dart @@ -6,7 +6,7 @@ class _Bloc extends Bloc<_Event, _State> _Bloc({ required this.prefController, }) : super(_State( - isEnable: prefController.isEnableExifValue, + isEnable: prefController.isEnableClientExifValue, isWifiOnly: prefController.shouldProcessExifWifiOnlyValue, )) { on<_Init>(_onInit); @@ -22,7 +22,7 @@ class _Bloc extends Bloc<_Event, _State> await Future.wait([ forEach( emit, - prefController.isEnableExifChange, + prefController.isEnableClientExifChange, onData: (data) => state.copyWith(isEnable: data), onError: (e, stackTrace) { _log.severe("[_onInit] Uncaught exception", e, stackTrace); @@ -43,7 +43,7 @@ class _Bloc extends Bloc<_Event, _State> void _onSetEnable(_SetEnable ev, Emitter<_State> emit) { _log.info(ev); - prefController.setEnableExif(ev.value); + prefController.setEnableClientExif(ev.value); } Future _onSetWifiOnly(_SetWifiOnly ev, Emitter<_State> emit) async {