From 7b0be4757356af46df1eb55d596f819c21b00f3e Mon Sep 17 00:00:00 2001 From: Peter Stone Date: Wed, 22 Jul 2026 19:14:44 +0000 Subject: Fix scroll regression and feed-setting reset on re-import - ReaderScreen: the direction-ratio gesture rewrite (using a generic, non-oriented detectDragGestures to compute a custom dx/dy ratio) broke scrolling entirely -- reported live as "the article view doesn't scroll at all anymore." Root cause: detectDragGestures' touch-slop detection is isotropic (claims the first bit of movement in ANY direction before it knows which way the gesture is going), unlike detectHorizontalDragGestures which is orientation-aware and simply never engages for a vertical- dominant drag. Reverted to detectHorizontalDragGestures, keeping the distance-based (not edge-anchored) commit threshold from the previous fix. Verified live: a long article now scrolls properly on a diagonal swipe, and a deliberate horizontal swipe still changes pages. - AddFeedScreen: both the OPML import and single-URL add built a bare FeedEntity(id, title, siteUrl) and upserted it (REPLACE) even when a feed with that id already existed -- silently wiping readerModeDisabled (and etag/lastModified/lastError) back to defaults on every re-import or re-add. This is exactly what made a feed's reader-mode toggle appear not to persist. Now preserves the existing row via .copy() when one exists. Verified live: set kottke.org's readerModeDisabled=1, re-imported the same OPML file (107 feeds), and confirmed the flag was still 1 afterward. --- .../java/org/terst/feedreader/ui/AddFeedScreen.kt | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'app/src/main/java/org/terst/feedreader/ui/AddFeedScreen.kt') diff --git a/app/src/main/java/org/terst/feedreader/ui/AddFeedScreen.kt b/app/src/main/java/org/terst/feedreader/ui/AddFeedScreen.kt index 5d19c90..066d8d9 100644 --- a/app/src/main/java/org/terst/feedreader/ui/AddFeedScreen.kt +++ b/app/src/main/java/org/terst/feedreader/ui/AddFeedScreen.kt @@ -63,7 +63,14 @@ fun AddFeedScreen(onDone: () -> Unit) { // as some larger number even though upsert already collapses them to one row each. val uniqueFeeds = imported.distinctBy { it.xmlUrl } for (feed in uniqueFeeds) { - db.feedDao().upsert(FeedEntity(id = feed.xmlUrl, title = feed.title, siteUrl = feed.htmlUrl)) + // upsert() REPLACEs the whole row -- for a feed that's already subscribed, + // building a bare FeedEntity here would silently wipe readerModeDisabled + // (and etag/lastModified/lastError) back to defaults on every re-import. + // Preserve the existing row's other fields; only title/siteUrl come from OPML. + val existing = db.feedDao().getById(feed.xmlUrl) + val entity = existing?.copy(title = feed.title, siteUrl = feed.htmlUrl ?: existing.siteUrl) + ?: FeedEntity(id = feed.xmlUrl, title = feed.title, siteUrl = feed.htmlUrl) + db.feedDao().upsert(entity) } FeedFetchWorker.fetchNow(context) status = "Imported ${uniqueFeeds.size} feed(s)" @@ -145,9 +152,13 @@ private suspend fun addFeedByUrl(context: android.content.Context, db: AppDataba if (!it.isSuccessful) return@withContext "Couldn't fetch feed: HTTP ${it.code}" val body = it.body ?: return@withContext "Empty response" val parsed = FeedParser.parse(body.byteStream()) - db.feedDao().upsert( - FeedEntity(id = feedUrl, title = parsed.title.ifBlank { feedUrl }, siteUrl = parsed.siteUrl) - ) + // Same REPLACE-wipes-other-fields concern as the OPML import path. + val existing = db.feedDao().getById(feedUrl) + val entity = existing?.copy( + title = parsed.title.ifBlank { feedUrl }, + siteUrl = parsed.siteUrl ?: existing.siteUrl + ) ?: FeedEntity(id = feedUrl, title = parsed.title.ifBlank { feedUrl }, siteUrl = parsed.siteUrl) + db.feedDao().upsert(entity) } FeedFetchWorker.fetchNow(context) "Added" -- cgit v1.2.3