news: remove dead feed-sort preference residual
- Commit
968f3f725b511a92c494586786bac98a7d7f3f07- Author
- Vayun Mathur <[email protected]>
- When
- 2026-12-02 02:36 UTC (4 days ago)
- Parents
c401bcd
The Top Stories / Latest toggle, its FeedSort enum, the Latest ordering branch, and the feed UI selector were already removed: FeedRanking is the single feed ordering (descending distinct source count, then newest first, then firstSeen, then id), and search keeps its NewsSearch relevance order. What remained was residual: NewsPrefs still defined the dead feed_sort DataStore key (LEGACY_FEED_SORT) and dropped it in clearLegacySourcePrefs, SettingsScreen KDoc still claimed a feed sort lives on the feed, and the prefs test was still named NewsPrefsSortTest after the sort it no longer tests. Remove the dead key and its cleanup line (an orphaned key in an old install is never read; the per-source disabled_sources cleanup is kept), fix the SettingsScreen doc to state there is no feed-order setting, and rename the test to NewsPrefsTest with a new noFeedSortPreferenceExists pin asserting the prefs owner exposes no sort member, accessor, or backing key. FeedScreenTest already pins that no Top stories / Latest affordance renders, and FeedRankingTest pins source-count-before-recency, so a newest-first (Latest) order cannot return unnoticed. News AGENTS.md already documents the single source-count ordering, so it needs no change. DAO/FeedMerger newest-first clauses are cache retention and search-candidate limits, not feed display order (the feed re-orders via FeedRanking), and are untouched, as is search relevance ordering. Verified: ./gradlew :news:lint :news:lintVitalRelease :news:testDevUnitTest green (BUILD SUCCESSFUL; lintVitalAnalyze ran, lintVitalRelease task itself SKIPPED by Gradle).
Diff
news/src/main/java/com/vayunmathur/news/data/NewsPrefs.kt
diff --git a/news/src/main/java/com/vayunmathur/news/data/NewsPrefs.kt b/news/src/main/java/com/vayunmathur/news/data/NewsPrefs.ktindex fcb6200af5..7904639c14 100644--- a/news/src/main/java/com/vayunmathur/news/data/NewsPrefs.kt+++ b/news/src/main/java/com/vayunmathur/news/data/NewsPrefs.kt@@ -45,11 +45,10 @@ class NewsPrefs(context: Context) { */ val localLocation: Flow<String?> = safeData.map { it[LOCAL_LOCATION]?.takeIf { v -> v.isNotBlank() } } - /** Drops retired preference state, if an old install left any. */+ /** Drops retired per-source preference state, if an old install left any. */ suspend fun clearLegacySourcePrefs() { appContext.newsDataStore.edit { prefs -> if (prefs.contains(LEGACY_DISABLED_SOURCES)) prefs.remove(LEGACY_DISABLED_SOURCES)- if (prefs.contains(LEGACY_FEED_SORT)) prefs.remove(LEGACY_FEED_SORT) } } @@ -74,7 +73,6 @@ class NewsPrefs(context: Context) { const val MIN_TEXT_SP = 13 const val MAX_TEXT_SP = 24 private val LEGACY_DISABLED_SOURCES = stringSetPreferencesKey("disabled_sources")- private val LEGACY_FEED_SORT = stringPreferencesKey("feed_sort") private val LOCAL_LOCATION = stringPreferencesKey("local_location") private val TEXT_SP = intPreferencesKey("reader_text_sp") private val SERIF = booleanPreferencesKey("reader_serif")
news/src/main/java/com/vayunmathur/news/ui/SettingsScreen.kt
diff --git a/news/src/main/java/com/vayunmathur/news/ui/SettingsScreen.kt b/news/src/main/java/com/vayunmathur/news/ui/SettingsScreen.ktindex 3a728f9a96..ec22fe9a96 100644--- a/news/src/main/java/com/vayunmathur/news/ui/SettingsScreen.kt+++ b/news/src/main/java/com/vayunmathur/news/ui/SettingsScreen.kt@@ -18,12 +18,11 @@ import com.vayunmathur.news.R import com.vayunmathur.news.platform.NewsViewModel /**- * News settings. The app had no settings screen before this (feed sort- * lives on the feed, reader options in the reader); this is the natural- * settings route following the app's Route/Navigation patterns, and it- * currently holds the Local news location preference. Picking a location- * is navigation ([com.vayunmathur.news.Route.LocalLocation]), not local- * screen state.+ * News settings: holds the Local news location preference (reader+ * options are in the reader). Picking a location is navigation+ * ([com.vayunmathur.news.Route.LocalLocation]), not local screen state.+ * There is no feed-order setting: the feed has one ordering (see+ * [com.vayunmathur.news.domain.FeedRanking]). */ @Composable fun SettingsScreen(
news/src/test/java/com/vayunmathur/news/data/NewsPrefsTest.kt
diff --git a/news/src/test/java/com/vayunmathur/news/data/NewsPrefsSortTest.kt b/news/src/test/java/com/vayunmathur/news/data/NewsPrefsTest.ktsimilarity index 71%rename from news/src/test/java/com/vayunmathur/news/data/NewsPrefsSortTest.ktrename to news/src/test/java/com/vayunmathur/news/data/NewsPrefsTest.ktindex f794958353..43ee0f0d09 100644--- a/news/src/test/java/com/vayunmathur/news/data/NewsPrefsSortTest.kt+++ b/news/src/test/java/com/vayunmathur/news/data/NewsPrefsTest.kt@@ -9,20 +9,31 @@ import org.robolectric.RobolectricTestRunner import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertNull+import kotlin.test.assertTrue /** Prefs: Local location persistence and retired-state cleanup. */ @RunWith(RobolectricTestRunner::class)-class NewsPrefsSortTest {+class NewsPrefsTest { @Test fun legacyCleanupDropsRetiredStateWithoutCrashing() = runBlocking { val context = ApplicationProvider.getApplicationContext<Application>() val prefs = NewsPrefs(context)- // Retired per-source / feed-sort state is dropped without crashing.+ // Retired per-source state is dropped without crashing. There is+ // no feed-order preference: NewsPrefs exposes no sort state. prefs.clearLegacySourcePrefs() prefs.setLocalLocation("Chicago, Illinois, United States") assertEquals("Chicago, Illinois, United States", prefs.localLocation.first()) } + @Test fun noFeedSortPreferenceExists() {+ // The feed has one ordering only, so the prefs owner must not+ // expose any sort state (member, accessor, or backing key).+ val members = NewsPrefs::class.java.declaredMethods.map { it.name } ++ NewsPrefs::class.java.declaredFields.map { it.name } ++ NewsPrefs.Companion::class.java.declaredFields.map { it.name }+ assertTrue(members.none { it.contains("sort", ignoreCase = true) }, members.toString())+ }+ @Test fun localLocationDefaultsUnsetAndPersistsAndClears() = runBlocking { val context = ApplicationProvider.getApplicationContext<Application>() val prefs = NewsPrefs(context)
news/src/test/java/com/vayunmathur/news/ui/FeedScreenTest.kt
diff --git a/news/src/test/java/com/vayunmathur/news/ui/FeedScreenTest.kt b/news/src/test/java/com/vayunmathur/news/ui/FeedScreenTest.ktindex 19bf4db9a8..c40b5303fe 100644--- a/news/src/test/java/com/vayunmathur/news/ui/FeedScreenTest.kt+++ b/news/src/test/java/com/vayunmathur/news/ui/FeedScreenTest.kt@@ -71,7 +71,7 @@ class FeedScreenTest { 0, rule.onAllNodesWithText("Sources").fetchSemanticsNodes().size, )- // No Latest / Top-stories mode switch exists any more.+ // No Latest / Top-stories mode switch exists: the feed has one ordering. assertEquals(0, rule.onAllNodesWithText("Top stories").fetchSemanticsNodes().size) assertEquals(0, rule.onAllNodesWithText("Latest").fetchSemanticsNodes().size) }