diff --git a/static/js/home.js b/static/js/home.js
index a689d20..e50cf7f 100644
--- a/static/js/home.js
+++ b/static/js/home.js
@@ -1,11 +1,11 @@
/**
* diora Home: what you were in the middle of, one click away — the book you're
- * reading, the next episode, your stations, Ambient.
+ * reading, the next episode, the news, your stations, Ambient.
*
* Built only from what the page already has: the book list (app.js), the
* podcast host (window.DioraPodcastHost in the browser and diora desktop,
* window.DioraNative in the Android app), the saved stations in the radio tab
- * and Drift (app.js __dioraAmbient*). Renders into #tab-home; the same file runs
+ * Drift (app.js __dioraAmbient*) and the feed reader (feeds.js __dioraFeeds*). Renders into #tab-home; the same file runs
* in the browser, diora desktop and the Android app (copied with static/js/).
* Written without ?. and ?? so old WebViews can still parse it.
*/
@@ -125,6 +125,56 @@
button + '';
}
+ // ---- Nachrichten --------------------------------------------------------------
+
+ // The briefing comes from the server, so it's fetched now and then, not every render.
+ let feeds = null;
+ let feedsAt = 0;
+ let feedsBusy = false;
+
+ function refreshFeeds(maxAgeMs) {
+ if (typeof window.__dioraFeedsSummary !== 'function' || feedsBusy || !online()) return;
+ if (Date.now() - feedsAt < maxAgeMs) return;
+ feedsBusy = true;
+ window.__dioraFeedsSummary().then(r => { feeds = r; }, () => {}).then(() => {
+ feedsAt = Date.now();
+ feedsBusy = false;
+ render();
+ });
+ }
+
+ function feedsSection() {
+ if (!document.getElementById('tab-feeds') || !feeds || !feeds.state) return '';
+ const s = feeds.state;
+ const sources = s.sources || [];
+ if (!sources.length) return '';
+ const hasNews = sources.some(x => x.kind === 'news');
+ const top = ((feeds.briefing && feeds.briefing.top) || []).slice(0, 4);
+ let body = '';
+ if (top.length) {
+ body = '