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