diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx index fbee59d..afbe230 100644 --- a/frontend/src/App.jsx +++ b/frontend/src/App.jsx @@ -4,7 +4,6 @@ import { Typography, Spin, ConfigProvider, theme } from "antd"; import { useState, useEffect } from "react"; import dayjs from "dayjs"; import Notification from "./components/Notification"; -import CachedFetch from "./utils/cache_get"; import CampusButtonGroup from "./components/CampusButtonGroup"; import DatePicker from "./components/DatePicker"; import BuildingPicker from "./components/BuildingPicker"; @@ -46,7 +45,7 @@ function App() { mql.addEventListener("change", matchMode); matchMode(mql); - CachedFetch("/api/get_data") + fetch("/api/get_data") .then((resp) => resp.json()) .then((resp) => { setResp(resp); diff --git a/frontend/src/components/ClassTimePicker.jsx b/frontend/src/components/ClassTimePicker.jsx index 0bf46ef..2f1fe6e 100644 --- a/frontend/src/components/ClassTimePicker.jsx +++ b/frontend/src/components/ClassTimePicker.jsx @@ -76,7 +76,6 @@ function ClassTimePicker(props) { const now_minute = fillZero(now.getMinutes()); for (let i = 0; i <= 13; i++) { - console.log(class_time[i], `${now_hour}:${now_minute}`); options.push({ label: classes[i], value: i, diff --git a/frontend/src/utils/cache_get.js b/frontend/src/utils/cache_get.js deleted file mode 100644 index e03439f..0000000 --- a/frontend/src/utils/cache_get.js +++ /dev/null @@ -1,45 +0,0 @@ -async function CachedFetch(url, options) { - let expiry = 60 * 30; - // let expiry = 1; - if (typeof options === "number") { - expiry = options; - options = undefined; - } else if (typeof options === "object") { - expiry = options.seconds || expiry; - } - if (url.includes("get_all")) { - expiry = 60 * 60 * 12; - // expiry = 1; - } - let cacheKey = url; - let cached = localStorage.getItem(cacheKey); - let whenCached = localStorage.getItem(cacheKey + ":ts"); - if (cached !== null && whenCached !== null) { - let age = (Date.now() - whenCached) / 1000; - if (age < expiry) { - let response = new Response(new Blob([cached])); - return Promise.resolve(response); - } else { - localStorage.removeItem(cacheKey); - localStorage.removeItem(cacheKey + ":ts"); - } - } - - const response_1 = await fetch(url, options); - if (response_1.status === 200) { - let ct = response_1.headers.get("Content-Type"); - if (ct && (ct.match(/application\/json/i) || ct.match(/text\//i))) { - response_1 - .clone() - .text() - .then((content) => { - localStorage.setItem(cacheKey, content); - localStorage.setItem(cacheKey + ":ts", Date.now()); - }); - } - } - - return response_1; -} - -export default CachedFetch; \ No newline at end of file