feat: use new db site, cache requests to avoid repeated unneeded fetch calls
This commit is contained in:
+6
-5
@@ -4,6 +4,7 @@ import { useState, useEffect, useMemo } from 'react';
|
||||
import { useInventoryStore } from '@/store/useInventoryStore';
|
||||
import styles from '../styles/Home.module.css';
|
||||
import { isNamedDLC } from '@/lib/utils';
|
||||
import { fetchCharacters, fetchItems, fetchOfferings, fetchCustomizations, fetchDLCs } from '@/lib/db';
|
||||
|
||||
export default function Home() {
|
||||
const store = useInventoryStore();
|
||||
@@ -18,11 +19,11 @@ export default function Home() {
|
||||
|
||||
useEffect(() => {
|
||||
Promise.all([
|
||||
fetch('/data/characters.json').then(r => r.json()).catch(() => []),
|
||||
fetch('/data/items.json').then(r => r.json()).catch(() => []),
|
||||
fetch('/data/offerings.json').then(r => r.json()).catch(() => []),
|
||||
fetch('/data/customization_items.json').then(r => r.json()).catch(() => []),
|
||||
fetch('/data/dlcs.json').then(r => r.json()).catch(() => [])
|
||||
fetchCharacters(),
|
||||
fetchItems(),
|
||||
fetchOfferings(),
|
||||
fetchCustomizations(),
|
||||
fetchDLCs()
|
||||
]).then(([chars, items, offerings, customizations, dlcs]) => {
|
||||
setCharCount(chars.length);
|
||||
setItemsCount(items.length);
|
||||
|
||||
Reference in New Issue
Block a user