Skip to content

A cross platform Audiobookshelf client for Android and iOS

Dart

fix: reload EQ settings on account switch

Barnabasfe20dd0dac25
diff --git a/lib/providers/auth_provider.dart b/lib/providers/auth_provider.dart
index 7cbec83b..b32ff30f 100644
--- a/lib/providers/auth_provider.dart
+++ b/lib/providers/auth_provider.dart
@@ -5,6 +5,7 @@ import 'package:shared_preferences/shared_preferences.dart';
import '../services/api_service.dart';
import '../services/android_auto_service.dart';
import '../services/audio_player_service.dart';
+import '../services/equalizer_service.dart';
import '../services/session_cache.dart';
import '../services/socket_service.dart';
import '../services/user_account_service.dart';
@@ -555,6 +556,11 @@ class AuthProvider extends ChangeNotifier {
// previous account's values cached in widget state.
PlayerSettings.notifySettingsChanged();
+ // Reload EQ settings from the new account's scope. Without this the
+ // EqualizerService singleton keeps the previous account's in-memory
+ // state and would write it back into the new scope on any change.
+ await EqualizerService().reloadForActiveAccount();
+
// Set credentials
_serverUrl = account.serverUrl;
_accessToken = account.token;
diff --git a/lib/services/equalizer_service.dart b/lib/services/equalizer_service.dart
index 7fa995c2..fa1caa6c 100644
--- a/lib/services/equalizer_service.dart
+++ b/lib/services/equalizer_service.dart
@@ -373,6 +373,22 @@ class EqualizerService extends ChangeNotifier {
}
}
+ /// Reload settings from the currently-scoped SharedPreferences. Call this
+ /// after switching user accounts so the singleton picks up the new user's
+ /// stored EQ config instead of keeping the previous user's in-memory state
+ /// (which would otherwise also get written back into the new user's scope
+ /// on the next save).
+ Future<void> reloadForActiveAccount() async {
+ await _loadSettings();
+ _currentItemId = null;
+ if (_enabled) {
+ await _applyCurrentSettings();
+ } else {
+ await _resetPlatform();
+ }
+ notifyListeners();
+ }
+
Future<void> _saveSettings() async {
await ScopedPrefs.setBool('eq_enabled', _enabled);
await ScopedPrefs.setString('eq_preset', _activePreset);