feat/freshrss-reader #6
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "refs/pull/6/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Expands the FreshRSS widget from a "counts only" display into a full interactive reader. Users can browse unread articles by category (or all-unread/starred), expand articles inline to read sanitized HTML content, mark items read/unread, star/unstar, and bulk-mark a stream as read — all without leaving the dashboard.
The compact header (FreshRSS unread count) variant continues to work via the existing, untouched
/api/freshrss/unreadroute and shares the same widget configuration.What's new
Server (
server/src/services/freshrss.service.ts+server/src/routes/api.routes.ts)/api/freshrss/itemsxt=readto filter/api/freshrss/categories/api/freshrss/markaction: read | unread | star | unstarfor one or many items/api/freshrss/mark-all-readreading-list,label/<name>,feed/<id>)All routes share a
FreshRSSConfig = { freshrssUrl, username, apiPassword }body shape (matches the existing/freshrss/unreadroute). The service module caches theClientLoginauth token and the short-lived write token per(url, user)and auto-refreshes on 401. The existing/freshrss/unreadroute is refactored to use the service; its response shape is unchanged so the compact header widget keeps working.Client (
client/src/components/widgets/FreshRSSWidget.tsx+ newFreshRSSArticle.tsx)HTML is sanitized with
isomorphic-dompurify(new client dep). Allowed attributes are restricted; links are forced totarget="_blank" rel="noopener noreferrer".Compatibility
App.tsxwidget map,WidgetConfigModalform,TabbedWidget, andHeader.tsx(compact variant) are all unchanged./api/freshrss/unreadand shows total unread.Testing
Tested end-to-end against a FreshRSS 1.28.1 instance with ~1,170 unread items across 4 categories:
Build verification:
docker compose buildproduces the production image cleanly;tscreports no new type errors. Pre-existing TypeScript errors in unrelated upstream files (docker.service.ts,system.service.ts,auth.routes.ts) are not introduced or worsened by this change.Notes for review
FreshRSS) and props so layout and per-user widget configs migrate without changes./freshrss/unreadroute in place to avoid breaking the compact header widget — could be removed in a follow-up if/freshrss/categoriesis preferred everywhere (categories.totalmatches).isomorphic-dompurify is for SSR (it bundles jsdom). This is a pure browser component — look at what it drags in: jsdom, cssstyle,
@asamuzakjp/css-color, @asamuzakjp/dom-selector, data-urls, html-encoding-sniffer, decimal.js, etc. The lockfile grows
substantially for something that's never needed at runtime in a Vite/browser build.
Should be just dompurify (and @types/dompurify as a dev dep). Drop-in replacement for the import — DOMPurify's browser build is
~50KB vs hundreds of KB of jsdom polyfills.
The description says "1 s delay, optimistic UI; reverts on error" but the actual code in handleExpand is immediate with no
setTimeout:
if (willExpand && !item.isRead) {
setItemRead(item, true); // no delay
}
Not necessarily wrong, but worth clarifying intent — an accidental click will immediately mark the item read and you'd have to
manually unmark it.
loadCategories() hits /api/freshrss/categories which does two upstream calls: fetchUnreadCount + fetchSubscriptions. Subscriptions
rarely change — this doubles the API traffic on every poll. The subscription list could be fetched once on load, or the polling
endpoint could hit /freshrss/unread (which already exists) instead.
DOMPurify.sanitize(html, {
ALLOWED_ATTR: ['href', 'src', 'alt', 'title', 'target', 'rel', ...],
ADD_ATTR: ['target', 'rel'],
});
ADD_ATTR allows these attributes through, it doesn't add them. Links in article HTML that don't already have target="_blank" will
open in the current tab. Not a security issue, just a UX one. Fix with a post-sanitize hook or dangerouslySetInnerHTML wrapper that
patches tags.
continuation is captured in the closure but only used when append = true. This causes loadItems to be recreated every time a page
is loaded (since continuation changes). Harmless in practice but slightly wasteful — passing continuation as a parameter would be
cleaner.