mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
move useBufferedFeeds to Home
This commit is contained in:
+1
-14
@@ -1,7 +1,6 @@
|
||||
import React, { useEffect } from 'react';
|
||||
import { Route, Routes, useLocation } from 'react-router-dom';
|
||||
import { Helmet } from 'react-helmet-async';
|
||||
import { useAccount, useBufferedFeeds } from '@plebbit/plebbit-react-hooks';
|
||||
import 'react-tooltip/dist/react-tooltip.css';
|
||||
import 'react-toastify/dist/ReactToastify.css';
|
||||
import useGeneralStore from './hooks/stores/useGeneralStore';
|
||||
@@ -27,7 +26,7 @@ import useSuccess from "./hooks/useSuccess";
|
||||
export default function App() {
|
||||
const {
|
||||
bodyStyle, setBodyStyle,
|
||||
defaultSubplebbits, setDefaultSubplebbits,
|
||||
setDefaultSubplebbits,
|
||||
isCaptchaOpen, setIsCaptchaOpen,
|
||||
setIsSettingsOpen,
|
||||
selectedStyle, setSelectedStyle,
|
||||
@@ -38,8 +37,6 @@ export default function App() {
|
||||
const location = useLocation();
|
||||
const isHomeRoute = location.pathname === "/";
|
||||
|
||||
const account = useAccount();
|
||||
|
||||
const [, setNewErrorMessage] = useError();
|
||||
const [, setNewSuccessMessage] = useSuccess();
|
||||
|
||||
@@ -57,16 +54,6 @@ export default function App() {
|
||||
return;
|
||||
}
|
||||
}, [setNewErrorMessage, setNewSuccessMessage]);
|
||||
|
||||
// preload default subs and subscriptions
|
||||
useBufferedFeeds({
|
||||
feedsOptions: [
|
||||
{subplebbitAddresses: defaultSubplebbits.map(
|
||||
(subplebbit) => subplebbit.address
|
||||
), sortType: 'active'},
|
||||
{subplebbitAddresses: account?.subscriptions, sortType: 'active'}
|
||||
]
|
||||
});
|
||||
|
||||
// preload banners
|
||||
useEffect(() => {
|
||||
|
||||
@@ -50,7 +50,7 @@ const Post = ({ content, postQuoteOnClick, postQuoteOnOver, postQuoteOnLeave, po
|
||||
|
||||
const regex = new RegExp(`${patternC}|${patternPC}|${patternU}|${patternP}`, 'g');
|
||||
|
||||
return children.flatMap((child, i) => {
|
||||
return children?.flatMap((child, i) => {
|
||||
if (typeof child !== 'string') {
|
||||
return child;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import React, { Fragment, useEffect, useRef } from 'react';
|
||||
import { Helmet } from 'react-helmet-async';
|
||||
import { useAccount } from '@plebbit/plebbit-react-hooks';
|
||||
import { useAccount, useBufferedFeeds } from '@plebbit/plebbit-react-hooks';
|
||||
import { Link, useNavigate } from 'react-router-dom';
|
||||
import { Container, Header, Logo, Page, Search, About, AboutTitle, AboutContent, Boards, BoardsTitle, BoardsContent, Footer } from '../styled/views/Home.styled';
|
||||
import BoardAvatar from '../BoardAvatar';
|
||||
@@ -29,6 +29,16 @@ const Home = () => {
|
||||
const prevStyle = useRef(selectedStyle);
|
||||
const prevBodyStyle = useRef(bodyStyle);
|
||||
|
||||
// preload default subs and subscriptions
|
||||
useBufferedFeeds({
|
||||
feedsOptions: [
|
||||
{subplebbitAddresses: defaultSubplebbits.map(
|
||||
(subplebbit) => subplebbit.address
|
||||
), sortType: 'active'},
|
||||
{subplebbitAddresses: account?.subscriptions, sortType: 'active'}
|
||||
]
|
||||
});
|
||||
|
||||
// prevent dark mode
|
||||
useEffect(() => {
|
||||
const currentPrevStyle = prevStyle.current;
|
||||
|
||||
Reference in New Issue
Block a user