Skip to content

A cross platform Audiobookshelf client for Android and iOS

Dart

Fix cross-account bleed in absorbing list and card button layout

Barnabas420cc91af3ca
diff --git a/lib/providers/_lp_absorbing.dart b/lib/providers/_lp_absorbing.dart
index cdb33831..598ab889 100644
--- a/lib/providers/_lp_absorbing.dart
+++ b/lib/providers/_lp_absorbing.dart
@@ -68,6 +68,7 @@ mixin _AbsorbingMixin on ChangeNotifier, _StateMixin, _CoreMixin {
id == 'continue-series' ||
id == 'downloaded-books') {
final isContinueSeries = id == 'continue-series';
+ final isDownloadedOnly = id == 'downloaded-books';
for (final e in (section['entities'] as List<dynamic>? ?? [])) {
if (e is Map<String, dynamic>) {
final itemId = e['id'] as String?;
@@ -77,6 +78,14 @@ mixin _AbsorbingMixin on ChangeNotifier, _StateMixin, _CoreMixin {
final episodeId = recentEpisode['id'] as String?;
if (episodeId != null) {
final key = '$itemId-$episodeId';
+ // Downloads are shared across accounts on disk; don't auto-add
+ // them to this account's absorbing list unless this account has
+ // played them or manually added them.
+ if (isDownloadedOnly &&
+ !_progressMap.containsKey(key) &&
+ !_manualAbsorbAdds.contains(key)) {
+ continue;
+ }
allowedKeys.add(key);
showEntities[itemId] = e;
if (!_manualAbsorbRemoves.contains(key)) {
@@ -86,6 +95,11 @@ mixin _AbsorbingMixin on ChangeNotifier, _StateMixin, _CoreMixin {
}
}
} else {
+ if (isDownloadedOnly &&
+ !_progressMap.containsKey(itemId) &&
+ !_manualAbsorbAdds.contains(itemId)) {
+ continue;
+ }
allowedKeys.add(itemId);
if (!_manualAbsorbRemoves.contains(itemId)) {
_absorbingIdsAdd(itemId, atFront: false);
diff --git a/lib/providers/auth_provider.dart b/lib/providers/auth_provider.dart
index 3634e2ec..657e68ad 100644
--- a/lib/providers/auth_provider.dart
+++ b/lib/providers/auth_provider.dart
@@ -534,6 +534,11 @@ class AuthProvider extends ChangeNotifier {
// Set the new account as active in the account service
UserAccountService().switchTo(account.serverUrl, account.username);
+ // Notify widgets that read scoped settings (e.g. card button layout) so
+ // they reload from the new account's ScopedPrefs instead of keeping the
+ // previous account's values cached in widget state.
+ PlayerSettings.notifySettingsChanged();
+
// Set credentials
_serverUrl = account.serverUrl;
_accessToken = account.token;