diff --git a/lib/data/services/plugin_sync_service.dart b/lib/data/services/plugin_sync_service.dart index 1dbc284d9..5c24279d4 100644 --- a/lib/data/services/plugin_sync_service.dart +++ b/lib/data/services/plugin_sync_service.dart @@ -1126,6 +1126,7 @@ class PluginSyncService extends ChangeNotifier { } _appendDisabledBuiltinSections(sections, order); await _prefs.setHomeSectionsConfig(sections); + await _syncSeerrHomeRowsWithSections(sections); appliedHomeSections = true; } } @@ -1201,6 +1202,7 @@ class PluginSyncService extends ChangeNotifier { sections.add(entry.copyWith(order: order++)); } await _prefs.setHomeSectionsConfig(sections); + await _syncSeerrHomeRowsWithSections(sections); } } } @@ -1302,10 +1304,16 @@ class PluginSyncService extends ChangeNotifier { } await _prefs.setHomeSectionsConfig(sections); + await _syncSeerrHomeRowsWithSections(sections); } /// Appends a disabled entry for every built-in HomeSectionType not already in /// [sections] so the settings UI shows every toggle. Returns the next order. + /// + /// A section the profile doesn't mention carries no opinion, so it lands + /// disabled rather than being re-derived from a toggle preference that + /// defaults to on. The preferences stay untouched because the profile's own + /// synced fields already set them, and writing false would push that back. int _appendDisabledBuiltinSections( List sections, int order, @@ -1315,33 +1323,32 @@ class PluginSyncService extends ChangeNotifier { if (type == prefs.HomeSectionType.none || present.contains(type)) { continue; } - - var isEnabled = false; - if (type == prefs.HomeSectionType.rewatch) { - isEnabled = _prefs.get(UserPreferences.displayRewatchRow); - } else if (type == prefs.HomeSectionType.sinceYouWatched1 || - type == prefs.HomeSectionType.sinceYouWatched2 || - type == prefs.HomeSectionType.sinceYouWatched3 || - type == prefs.HomeSectionType.sinceYouWatched4 || - type == prefs.HomeSectionType.sinceYouWatched5) { - final localPref = switch (type) { - prefs.HomeSectionType.sinceYouWatched1 => UserPreferences.sinceYouWatched1Enabled, - prefs.HomeSectionType.sinceYouWatched2 => UserPreferences.sinceYouWatched2Enabled, - prefs.HomeSectionType.sinceYouWatched3 => UserPreferences.sinceYouWatched3Enabled, - prefs.HomeSectionType.sinceYouWatched4 => UserPreferences.sinceYouWatched4Enabled, - prefs.HomeSectionType.sinceYouWatched5 => UserPreferences.sinceYouWatched5Enabled, - _ => throw StateError('Invalid type'), - }; - isEnabled = _prefs.get(localPref); - } - sections.add( - HomeSectionConfig(type: type, enabled: isEnabled, order: order++), + HomeSectionConfig(type: type, enabled: false, order: order++), ); } return order; } + /// Seerr home rows keep their own copy of the enabled state that the settings + /// screens write alongside the section layout, so mirror it here too. Without + /// this the home view gates Seerr rows on stale values after a sync. + Future _syncSeerrHomeRowsWithSections( + List sections, + ) async { + final enabledByType = { + for (final section in sections) section.type: section.enabled, + }; + final updated = _seerrPrefs.homeRowsConfig + .map( + (row) => row.copyWith( + enabled: enabledByType[row.type.homeSectionType] ?? false, + ), + ) + .toList(); + await _seerrPrefs.setHomeRowsConfig(updated); + } + /// Applies one table-driven field from an incoming profile. void _applySyncedField(Map data, SyncedField field) { switch (field.codec) { @@ -1715,6 +1722,16 @@ class PluginSyncService extends ChangeNotifier { prefs.HomeSectionType.sonarrCalendar => UserPreferences.enableSonarrCalendar, prefs.HomeSectionType.rewatch => UserPreferences.displayRewatchRow, + prefs.HomeSectionType.sinceYouWatched1 => + UserPreferences.sinceYouWatched1Enabled, + prefs.HomeSectionType.sinceYouWatched2 => + UserPreferences.sinceYouWatched2Enabled, + prefs.HomeSectionType.sinceYouWatched3 => + UserPreferences.sinceYouWatched3Enabled, + prefs.HomeSectionType.sinceYouWatched4 => + UserPreferences.sinceYouWatched4Enabled, + prefs.HomeSectionType.sinceYouWatched5 => + UserPreferences.sinceYouWatched5Enabled, _ => null, }; } diff --git a/lib/preference/home_section_config.dart b/lib/preference/home_section_config.dart index 297df672f..df6f86812 100644 --- a/lib/preference/home_section_config.dart +++ b/lib/preference/home_section_config.dart @@ -326,6 +326,39 @@ class HomeSectionConfig { enabled: false, order: 39, ), + // These carry a toggle preference too, but they still need a section entry. + // Without one there was nowhere for turning the row off to persist, so the + // next sync kept bringing it back. + HomeSectionConfig( + type: HomeSectionType.sinceYouWatched1, + enabled: false, + order: 40, + ), + HomeSectionConfig( + type: HomeSectionType.sinceYouWatched2, + enabled: false, + order: 41, + ), + HomeSectionConfig( + type: HomeSectionType.sinceYouWatched3, + enabled: false, + order: 42, + ), + HomeSectionConfig( + type: HomeSectionType.sinceYouWatched4, + enabled: false, + order: 43, + ), + HomeSectionConfig( + type: HomeSectionType.sinceYouWatched5, + enabled: false, + order: 44, + ), + HomeSectionConfig( + type: HomeSectionType.rewatch, + enabled: false, + order: 45, + ), ]; static bool isSupportedJson(Map json) { diff --git a/lib/preference/seerr_preferences.dart b/lib/preference/seerr_preferences.dart index e2c621f36..5e41b4ad4 100644 --- a/lib/preference/seerr_preferences.dart +++ b/lib/preference/seerr_preferences.dart @@ -143,7 +143,7 @@ class SeerrPreferences { if (seerrType == null || !enabled) return false; final config = homeRowsConfig.firstWhere( (c) => c.type == seerrType, - orElse: () => SeerrRowConfig(type: seerrType, enabled: true, order: 0), + orElse: () => SeerrRowConfig(type: seerrType, enabled: false, order: 0), ); return config.enabled; }