#1238 tagging while vaults are unlocked does not yield recent tags visible when vaults are locked
This commit is contained in:
parent
00a4890fb1
commit
104403948c
5 changed files with 37 additions and 7 deletions
|
@ -19,6 +19,7 @@ All notable changes to this project will be documented in this file.
|
|||
- crash when loading large collection
|
||||
- Viewer: copying content URI item
|
||||
- Albums: creating album with same name as existing empty directory
|
||||
- Privacy: tagging while vaults are unlocked does not yield recent tags visible when vaults are locked
|
||||
|
||||
## <a id="v1.11.16"></a>[v1.11.16] - 2024-10-10
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import 'package:aves/model/filters/filters.dart';
|
||||
import 'package:aves/model/settings/defaults.dart';
|
||||
import 'package:aves/model/vaults/vaults.dart';
|
||||
import 'package:aves/widgets/aves_app.dart';
|
||||
import 'package:aves_model/aves_model.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
@ -7,6 +8,10 @@ import 'package:flutter/widgets.dart';
|
|||
mixin AppSettings on SettingsAccess {
|
||||
static const int recentFilterHistoryMax = 20;
|
||||
|
||||
void initAppSettings() {
|
||||
vaults.addListener(_onVaultsChanged);
|
||||
}
|
||||
|
||||
bool get hasAcceptedTerms => getBool(SettingKeys.hasAcceptedTermsKey) ?? SettingsDefaults.hasAcceptedTerms;
|
||||
|
||||
set hasAcceptedTerms(bool newValue) => set(SettingKeys.hasAcceptedTermsKey, newValue);
|
||||
|
@ -106,7 +111,24 @@ mixin AppSettings on SettingsAccess {
|
|||
|
||||
set recentDestinationAlbums(List<String> newValue) => set(SettingKeys.recentDestinationAlbumsKey, newValue.take(recentFilterHistoryMax).toList());
|
||||
|
||||
List<CollectionFilter> get recentTags => (getStringList(SettingKeys.recentTagsKey) ?? []).map(CollectionFilter.fromJson).nonNulls.toList();
|
||||
// recent tags
|
||||
|
||||
set recentTags(List<CollectionFilter> newValue) => set(SettingKeys.recentTagsKey, newValue.take(recentFilterHistoryMax).map((filter) => filter.toJson()).toList());
|
||||
List<CollectionFilter> get _recentTags => (getStringList(SettingKeys.recentTagsKey) ?? []).map(CollectionFilter.fromJson).nonNulls.toList();
|
||||
|
||||
set _recentTags(List<CollectionFilter> newValue) => set(SettingKeys.recentTagsKey, newValue.take(recentFilterHistoryMax).map((filter) => filter.toJson()).toList());
|
||||
|
||||
// when vaults are unlocked, recent tags are transient and not persisted
|
||||
List<CollectionFilter>? _protectedRecentTags;
|
||||
|
||||
List<CollectionFilter> get recentTags => vaults.needProtection ? _protectedRecentTags ?? List.of(_recentTags) : _recentTags;
|
||||
|
||||
set recentTags(List<CollectionFilter> newValue) {
|
||||
if (vaults.needProtection) {
|
||||
_protectedRecentTags = newValue;
|
||||
} else {
|
||||
_recentTags = newValue;
|
||||
}
|
||||
}
|
||||
|
||||
void _onVaultsChanged() => _protectedRecentTags = null;
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ import 'package:aves/model/settings/modules/navigation.dart';
|
|||
import 'package:aves/model/settings/modules/privacy.dart';
|
||||
import 'package:aves/model/settings/modules/search.dart';
|
||||
import 'package:aves/model/settings/modules/viewer.dart';
|
||||
import 'package:aves/model/vaults/vaults.dart';
|
||||
import 'package:aves/ref/bursts.dart';
|
||||
import 'package:aves/services/accessibility_service.dart';
|
||||
import 'package:aves/services/common/services.dart';
|
||||
|
@ -69,6 +70,7 @@ class Settings with ChangeNotifier, SettingsAccess, AppSettings, DisplaySettings
|
|||
..clear();
|
||||
_subscriptions.add(_platformSettingsChangeChannel.receiveBroadcastStream().listen((event) => _onPlatformSettingsChanged(event as Map?)));
|
||||
}
|
||||
initAppSettings();
|
||||
}
|
||||
|
||||
Future<void> reload() => store.reload();
|
||||
|
|
|
@ -82,10 +82,7 @@ abstract class CollectionSource with SourceBase, AlbumMixin, CountryMixin, Place
|
|||
_onFilterVisibilityChanged(newlyVisibleFilters);
|
||||
}
|
||||
});
|
||||
vaults.addListener(() {
|
||||
final newlyVisibleFilters = vaults.vaultDirectories.whereNot(vaults.isLocked).map((v) => AlbumFilter(v, null)).toSet();
|
||||
_onFilterVisibilityChanged(newlyVisibleFilters);
|
||||
});
|
||||
vaults.addListener(_onVaultsChanged);
|
||||
}
|
||||
|
||||
@mustCallSuper
|
||||
|
@ -93,6 +90,7 @@ abstract class CollectionSource with SourceBase, AlbumMixin, CountryMixin, Place
|
|||
if (kFlutterMemoryAllocationsEnabled) {
|
||||
LeakTracking.dispatchObjectDisposed(object: this);
|
||||
}
|
||||
vaults.removeListener(_onVaultsChanged);
|
||||
_rawEntries.forEach((v) => v.dispose());
|
||||
}
|
||||
|
||||
|
@ -598,6 +596,11 @@ abstract class CollectionSource with SourceBase, AlbumMixin, CountryMixin, Place
|
|||
analyze(null, entries: candidateEntries);
|
||||
}
|
||||
}
|
||||
|
||||
void _onVaultsChanged() {
|
||||
final newlyVisibleFilters = vaults.vaultDirectories.whereNot(vaults.isLocked).map((v) => AlbumFilter(v, null)).toSet();
|
||||
_onFilterVisibilityChanged(newlyVisibleFilters);
|
||||
}
|
||||
}
|
||||
|
||||
class AspectRatioChangedEvent {}
|
||||
|
|
|
@ -184,8 +184,10 @@ class Vaults extends ChangeNotifier {
|
|||
|
||||
void _onScreenOff() => lock(all.where((v) => v.autoLockScreenOff).map((v) => v.path).toSet());
|
||||
|
||||
bool get needProtection => _unlockedDirPaths.isNotEmpty;
|
||||
|
||||
void _onLockStateChanged() {
|
||||
windowService.secureScreen(_unlockedDirPaths.isNotEmpty);
|
||||
windowService.secureScreen(needProtection);
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue