浏览代码

Some improvements to CommaFeed, and cleaning up description in index

Kirk Trombley 5 年之前
父节点
当前提交
1df3757601
共有 2 个文件被更改,包括 12 次插入4 次删除
  1. 1 1
      public/index.html
  2. 11 3
      src/components/tiles/CommaFeed.jsx

+ 1 - 1
public/index.html

@@ -7,7 +7,7 @@
     <meta name="theme-color" content="#000000" />
     <meta
       name="description"
-      content="Web site created using create-react-app"
+      content="Hiram Centralized Status Page"
     />
     <link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
     <title>Hiram Status</title>

+ 11 - 3
src/components/tiles/CommaFeed.jsx

@@ -2,20 +2,28 @@ import React from "react";
 import { OK } from "../shared/StatusMessage";
 import Tile from "../shared/Tile";
 import useApi from "../../hooks/useApi";
+import useHealthPolling from "../../hooks/useHealthPolling";
 
 const ms = 1000 * 60 * 20;
-const fetchOptions = { credentials: "include" };
+const fetchOptions = { credentials: "same-origin" };
 const apiOptions = { ms, fetchOptions };
 const homepage = "https://kirkleon.ddns.net/commafeed/";
 const unreadLookup = "https://kirkleon.ddns.net/commafeed/rest/category/entries?id=all&limit=20&offset=0&order=desc&readType=unread";
 
 export default () => {
-  const [health, data] = useApi(unreadLookup, apiOptions);
+  const health = useHealthPolling(homepage, { ms });
+  const [apiRes, data] = useApi(unreadLookup, apiOptions);
+
+  const message = health !== OK
+                ? null
+                : apiRes === OK
+                ? `${data.entries.length} item(s) unread`
+                : "Could not retrieve unread"
 
   return <Tile
     link={homepage}
     title="CommaFeed"
     health={health}
-    data={health === OK ? `${data.entries.length} item(s) unread` : null}
+    data={message}
   />
 }