do not auto-load the first item in the reading pane
[rss-reader.git] / src / server.ts
index c2a3fdaf1163b43d80da4e7dd6ce0f1525fac57a..4e1404e5385254aff7098fa56191ee991e2f3cf7 100644 (file)
@@ -60,6 +60,9 @@ function apiDelete(endpoint: string, fn: WrappedApiHandler, view?: (arr: any) =>
   apiWrapper('delete', endpoint, fn, view);
 }
 
+apiPost('/login', async (req, res): Promise<any> => {
+});
+
 apiPost('/feeds', async (req, res): Promise<any> => {
   // get info about the feed
   const url = req.body.link;
@@ -156,8 +159,9 @@ apiGet('/feeds/:feed_id/items', async (req, res): Promise<any> => {
       <ul class="scrollable list" id="feed-item-list">
   ${feedData.items.map((item: any, index: number) => {
     const read = !!item.read_at;
+    const first = index === 0;
     return `<li>
-      <a href="#" class="${index === 0 ? 'active': ''} ${read ? '': 'unread'}" data-actions="activate" hx-get="/feeds/${item.feed_id}/items/${item.id}" hx-trigger="${index === 0 ? 'load,': ''}click" hx-target="#reading-pane" data-feed-item-id="${item.id}" data-feed-id="${item.feed_id}">${item.title}
+      <a href="#" class="${first ? 'active': ''} ${read ? '': 'unread'}" data-actions="activate" hx-get="/feeds/${item.feed_id}/items/${item.id}" hx-trigger="click" hx-target="#reading-pane" data-feed-item-id="${item.id}" data-feed-id="${item.feed_id}">${item.title}
       <span class="date">${reasonable(new Date(item.pub_date * 1000))}</span>
       </a>
     </li>