feat: use new db site, cache requests to avoid repeated unneeded fetch calls
This commit is contained in:
@@ -7,6 +7,7 @@ import shared from '../../styles/shared.module.css';
|
||||
import styles from '../../styles/Customizations.module.css';
|
||||
|
||||
import { getFileName, cleanFolderName, isKiller } from '../../lib/utils';
|
||||
import { fetchCharacters, fetchCustomizations } from '../../lib/db';
|
||||
import { Character, CustomizationItem, RoleFilter, Tab, TAB_CATEGORIES, CATEGORY_ORDER } from './types';
|
||||
import CharacterPicker from './CharacterPicker';
|
||||
import CharacterCosmetics from './CharacterCosmetics';
|
||||
@@ -31,13 +32,11 @@ export default function CustomizationsPage() {
|
||||
const [page, setPage] = useState(1);
|
||||
|
||||
useEffect(() => {
|
||||
Promise.all([
|
||||
fetch('/data/customization_items.json').then(r => r.json()).catch(() => []),
|
||||
fetch('/data/characters.json').then(r => r.json()).catch(() => []),
|
||||
]).then(([items, chars]) => {
|
||||
setAllItems(items);
|
||||
setCharacters(chars);
|
||||
});
|
||||
Promise.all([fetchCustomizations(), fetchCharacters()])
|
||||
.then(([items, chars]) => {
|
||||
setAllItems(items);
|
||||
setCharacters(chars);
|
||||
});
|
||||
}, []);
|
||||
|
||||
useEffect(() => { setPage(1); }, [tab, search]);
|
||||
|
||||
Reference in New Issue
Block a user