mirror of
https://github.com/FoggedLens/deflock-app.git
synced 2026-07-09 22:18:38 +02:00
Rework profile FOVs - 360 checkbox
This commit is contained in:
@@ -57,6 +57,28 @@ class ProfileState extends ChangeNotifier {
|
||||
_customOrder = prefs.getStringList(_profileOrderPrefsKey) ?? [];
|
||||
}
|
||||
|
||||
/// Reload all profiles from storage (useful after migrations modify stored profiles)
|
||||
Future<void> reloadFromStorage() async {
|
||||
// Preserve enabled state by ID
|
||||
final enabledIds = _enabled.map((p) => p.id).toSet();
|
||||
|
||||
// Clear and reload profiles
|
||||
_profiles.clear();
|
||||
_profiles.addAll(await ProfileService().load());
|
||||
|
||||
// Restore enabled state for profiles that still exist
|
||||
_enabled.clear();
|
||||
_enabled.addAll(_profiles.where((p) => enabledIds.contains(p.id)));
|
||||
|
||||
// Safety: Always have at least one enabled profile
|
||||
if (_enabled.isEmpty && _profiles.isNotEmpty) {
|
||||
final builtIn = _profiles.firstWhere((profile) => profile.builtin, orElse: () => _profiles.first);
|
||||
_enabled.add(builtIn);
|
||||
}
|
||||
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void toggleProfile(NodeProfile p, bool e) {
|
||||
if (e) {
|
||||
_enabled.add(p);
|
||||
|
||||
Reference in New Issue
Block a user