diff options
Diffstat (limited to 'app/src/main/java/org/terst/feedreader/ui')
| -rw-r--r-- | app/src/main/java/org/terst/feedreader/ui/LinkReaderScreen.kt | 13 | ||||
| -rw-r--r-- | app/src/main/java/org/terst/feedreader/ui/ReaderScreen.kt | 20 |
2 files changed, 28 insertions, 5 deletions
diff --git a/app/src/main/java/org/terst/feedreader/ui/LinkReaderScreen.kt b/app/src/main/java/org/terst/feedreader/ui/LinkReaderScreen.kt index 4ed0722..72f6c1f 100644 --- a/app/src/main/java/org/terst/feedreader/ui/LinkReaderScreen.kt +++ b/app/src/main/java/org/terst/feedreader/ui/LinkReaderScreen.kt @@ -51,6 +51,7 @@ import org.terst.feedreader.data.DEFAULT_READER_FONT_SIZE_PX import org.terst.feedreader.data.Settings import org.terst.feedreader.data.ensureStandaloneArticle import org.terst.feedreader.data.saveArticleToStash +import org.terst.feedreader.data.loadCachedExtraction import org.terst.feedreader.data.urlToArticleId import org.terst.feedreader.readability.ReaderExtractor import java.net.URLEncoder @@ -95,9 +96,15 @@ fun LinkReaderScreen(url: String, onBack: () -> Unit, onOpenLink: (String) -> Un LaunchedEffect(url) { val existing = db.articleDao().getById(articleId) article = existing - if (existing?.extractedContent != null) { - extractedTitle = existing.title - extractedContent = existing.extractedContent + // A cached extraction can be the site's cookie-consent notice rather than the + // article (see CachedExtraction) -- drop it and extract again instead of showing + // a cookie disclaimer as the page. + val cached = loadCachedExtraction(existing?.extractedContent) { + db.articleDao().clearExtractedContent(articleId) + } + if (cached.content != null) { + extractedTitle = existing?.title + extractedContent = cached.content } else { val extracted = ReaderExtractor.extract(context, url) val content = extracted?.content diff --git a/app/src/main/java/org/terst/feedreader/ui/ReaderScreen.kt b/app/src/main/java/org/terst/feedreader/ui/ReaderScreen.kt index 6240b77..f08088b 100644 --- a/app/src/main/java/org/terst/feedreader/ui/ReaderScreen.kt +++ b/app/src/main/java/org/terst/feedreader/ui/ReaderScreen.kt @@ -68,6 +68,7 @@ import org.terst.feedreader.data.Settings import org.terst.feedreader.data.ensureStandaloneArticle import org.terst.feedreader.data.saveArticleToStash import org.terst.feedreader.data.setReaderModeEnabled +import org.terst.feedreader.data.loadCachedExtraction import org.terst.feedreader.readability.ReaderExtractor import java.net.URLEncoder @@ -219,15 +220,26 @@ private fun ReaderContent( feed = loadedFeed feedContent = loaded.feedContentHtml - readerContent = loaded.extractedContent + // A previously-cached extraction can be the site's cookie-consent notice rather + // than the article (reported live on a New Republic feature). That is dropped + // from the cache on read, which leaves nothing to show -- so re-extract, or the + // repair would just turn a wrong article into a blank one. + val cachedExtraction = loadCachedExtraction(loaded.extractedContent) { + db.articleDao().clearExtractedContent(articleId) + } + readerContent = cachedExtraction.content // Reader mode is NEVER heuristic/automatic (no more "content looks thin, switch // for you") -- it strictly follows the feed's persisted, explicitly-set opt-in. // Once a feed has it on, articles from it default to the extracted view and // auto-extract on open (that's the point of persisting it per-feed: no re-tapping - // per article), but nothing here ever turns it on by itself. + // per article), but nothing here ever turns it on by itself. Replacing a discarded + // consent notice does not turn it on either -- for a feed-less saved article there + // is no feed to opt in, and the reader falls back to the extracted content anyway. if (loadedFeed?.readerModeEnabled == true) { isReaderMode = true + } + if (loadedFeed?.readerModeEnabled == true || cachedExtraction.discardedConsentNotice) { if (readerContent == null) { isExtracting = true val result = ReaderExtractor.extractResult(context, loaded.link) @@ -509,6 +521,10 @@ private fun ReaderContent( appendLine("Session isReaderMode: $isReaderMode") appendLine("isSaved: ${a?.isSaved}, stashArtifactId: ${a?.stashArtifactId}") appendLine("extractedContent cached: ${readerContent != null}") + // Without this, a report about bad/absent reader content could + // not say whether extraction had failed, let alone how -- which + // is exactly what the cookie-disclaimer report ran into. + appendLine("Last extraction error: ${extractionError ?: "none"}") } val clipboard = context.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager clipboard.setPrimaryClip(ClipData.newPlainText("Bug report", report)) |
