diff options
| author | Peter Stone <thepeterstone@gmail.com> | 2026-07-22 19:14:44 +0000 |
|---|---|---|
| committer | Peter Stone <thepeterstone@gmail.com> | 2026-07-22 19:14:44 +0000 |
| commit | 7b0be4757356af46df1eb55d596f819c21b00f3e (patch) | |
| tree | 53d1fb08c5e4d32a7a53c9084dcdb8474fcfb5eb /app/src/main/java/org/terst/feedreader/ui/AddFeedScreen.kt | |
| parent | 36ed34cd9ccd7388b96510e0225afe96979403a9 (diff) | |
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.
Diffstat (limited to 'app/src/main/java/org/terst/feedreader/ui/AddFeedScreen.kt')
| -rw-r--r-- | app/src/main/java/org/terst/feedreader/ui/AddFeedScreen.kt | 19 |
1 files changed, 15 insertions, 4 deletions
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" |
