perf(app): optimize loading times by using stored values of subplebbits and comments instead of fetching them multiple times

This commit is contained in:
Tom (plebeius.eth)
2025-03-05 17:10:26 +01:00
parent 97a415d071
commit 8557ebb3a7
8 changed files with 72 additions and 48 deletions
+2 -2
View File
@@ -1,8 +1,8 @@
import { useState } from 'react';
import { Link, useLocation } from 'react-router-dom';
import useSubplebbitsStore from '@plebbit/plebbit-react-hooks/dist/stores/subplebbits';
import { HomeLogo } from '../home';
import styles from './not-found.module.css';
import { useSubplebbit } from '@plebbit/plebbit-react-hooks';
const totalNotFoundImages = 2;
@@ -18,7 +18,7 @@ const NotFoundImage = () => {
const NotFound = () => {
const location = useLocation();
const subplebbitAddress = location.pathname.startsWith('/p/') ? location.pathname.split('/')[2] : '';
const subplebbit = useSubplebbit({ subplebbitAddress });
const subplebbit = useSubplebbitsStore((state) => state.subplebbits[subplebbitAddress]);
const { address, shortAddress } = subplebbit || {};
return (