diff --git a/src/pages/components/user-info/globalStats.jsx b/src/pages/components/user-info/globalStats.jsx
index 3e06cbe..e98d137 100644
--- a/src/pages/components/user-info/globalStats.jsx
+++ b/src/pages/components/user-info/globalStats.jsx
@@ -14,6 +14,10 @@ function GlobalStats(props) {
const [allStats, setAllStats] = useState({});
const token = localStorage.getItem("token");
+ const [prefs, setPrefs] = useState(
+ localStorage.getItem("PREF_GLOBAL_STATS") != undefined ? JSON.parse(localStorage.getItem("PREF_GLOBAL_STATS")) : []
+ );
+
function fetchStats(hours = 24, setMethod = setDayStats) {
axios
.post(
@@ -37,12 +41,12 @@ function GlobalStats(props) {
useEffect(() => {
const fetchData = async () => {
try {
- fetchStats(24, setDayStats);
- fetchStats(24 * 7, setWeekStats);
- fetchStats(24 * 30, setMonthStats);
- fetchStats(24 * 180, setd180Stats);
- fetchStats(24 * 365, setd365Stats);
- fetchStats(24 * 999, setAllStats);
+ if (!prefs.includes("1")) fetchStats(24, setDayStats);
+ if (!prefs.includes("7")) fetchStats(24 * 7, setWeekStats);
+ if (!prefs.includes("30")) fetchStats(24 * 30, setMonthStats);
+ if (!prefs.includes("180")) fetchStats(24 * 180, setd180Stats);
+ if (!prefs.includes("365")) fetchStats(24 * 365, setd365Stats);
+ if (!prefs.includes("ALL")) fetchStats(24 * 999, setAllStats);
} catch (error) {
console.log(error);
}
@@ -59,12 +63,12 @@ function GlobalStats(props) {