pull/40/head
Tim Pechersky 2021-08-02 22:46:40 +08:00
rodzic 0915d363e9
commit c3b481b042
4 zmienionych plików z 27 dodań i 43 usunięć

Wyświetl plik

@ -1,4 +1,10 @@
import React, { useEffect, Suspense, useContext, useState } from "react"; import React, {
useLayoutEffect,
useEffect,
Suspense,
useContext,
useState,
} from "react";
import { import {
Flex, Flex,
Heading, Heading,
@ -83,23 +89,12 @@ const Homepage = () => {
assets["background3840"] = `${AWS_PATH}/background3840.png`; assets["background3840"] = `${AWS_PATH}/background3840.png`;
}, []); }, []);
useEffect(() => { useLayoutEffect(() => {
console.log( if (backgroundLoaded3840) {
"isLargerChanged, ",
isLargerThan720px,
isLargerThan1920px,
isLargerThan2880px,
isLargerThan3840px,
backgroundLoaded720,
backgroundLoaded1920,
backgroundLoaded2880,
backgroundLoaded3840
);
if (isLargerThan3840px && backgroundLoaded3840) {
setBackground("background3840"); setBackground("background3840");
} else if (isLargerThan2880px && backgroundLoaded2880) { } else if (backgroundLoaded2880) {
setBackground("background2880"); setBackground("background2880");
} else if (isLargerThan1920px && backgroundLoaded1920) { } else if (backgroundLoaded1920) {
setBackground("background1920"); setBackground("background1920");
} else { } else {
setBackground("background720"); setBackground("background720");
@ -127,26 +122,32 @@ const Homepage = () => {
} }
}, [isInit, router]); }, [isInit, router]);
useEffect(() => { useLayoutEffect(() => {
console.log("rerender check"); console.log("rerender check");
const imageLoader720 = new Image(); const imageLoader720 = new Image();
imageLoader720.src = `${AWS_PATH}/background720.png`; imageLoader720.src = `${AWS_PATH}/background720.png`;
imageLoader720.onload = () => { imageLoader720.onload = () => {
setBackgroundLoaded720(true); setBackgroundLoaded720(true);
}; };
}, []);
useLayoutEffect(() => {
const imageLoader1920 = new Image(); const imageLoader1920 = new Image();
imageLoader1920.src = `${AWS_PATH}/background1920.png`; imageLoader1920.src = `${AWS_PATH}/background1920.png`;
imageLoader1920.onload = () => { imageLoader1920.onload = () => {
setBackgroundLoaded1920(true); setBackgroundLoaded1920(true);
}; };
}, []);
useLayoutEffect(() => {
const imageLoader2880 = new Image(); const imageLoader2880 = new Image();
imageLoader2880.src = `${AWS_PATH}/background2880.png`; imageLoader2880.src = `${AWS_PATH}/background2880.png`;
imageLoader2880.onload = () => { imageLoader2880.onload = () => {
setBackgroundLoaded2880(true); setBackgroundLoaded2880(true);
}; };
}, []);
useLayoutEffect(() => {
const imageLoader3840 = new Image(); const imageLoader3840 = new Image();
imageLoader3840.src = `${AWS_PATH}/background3840.png`; imageLoader3840.src = `${AWS_PATH}/background3840.png`;
imageLoader3840.onload = () => { imageLoader3840.onload = () => {
@ -154,7 +155,6 @@ const Homepage = () => {
}; };
}, []); }, []);
console.log("backgroundLoaded", background);
return ( return (
<Fade in> <Fade in>
@ -191,16 +191,18 @@ const Homepage = () => {
minH="100vh" minH="100vh"
// bgColor="primary.1200" // bgColor="primary.1200"
> >
<chakra.header boxSize="full"> <chakra.header boxSize="full" minH="100vh">
<Box <Box
// h="100%" // h="100%"
// w="full" // w="full"
// transition="" // transition=""
// bgPos={["initial", "initial", "center", null, "center"]} // bgPos={["initial", "initial", "center", null, "center"]}
bgPos="bottom" bgPos="bottom"
bgColor="transparent"
backgroundImage={`url(${assets[`${background}`]})`} backgroundImage={`url(${assets[`${background}`]})`}
bgSize="cover" bgSize="cover"
boxSize="full" boxSize="full"
minH="100vh"
// bgP // bgP
// h="container.sm" // h="container.sm"
// h={backgroundH} // h={backgroundH}

Wyświetl plik

@ -63,7 +63,7 @@ const EntriesNavigation = () => {
const ui = useContext(UIContext); const ui = useContext(UIContext);
const { isOpen, onOpen, onClose } = useDisclosure(); const { isOpen, onOpen, onClose } = useDisclosure();
const { subscriptionsCache } = useSubscriptions(); const { subscriptionsCache } = useSubscriptions();
const [newFilterState, _setNewFilterState] = useState([ const [newFilterState, setNewFilterState] = useState([
{ {
type: FILTER_TYPES.ADDRESS, type: FILTER_TYPES.ADDRESS,
direction: DIRECTIONS.SOURCE, direction: DIRECTIONS.SOURCE,
@ -73,17 +73,6 @@ const EntriesNavigation = () => {
]); ]);
const [filterState, setFilterState] = useState([]); const [filterState, setFilterState] = useState([]);
const setNewFilterState = useCallback(
(props) => {
console.log(
"setNewFilterState",
props,
subscriptionsCache.data.subscriptions[0].id
);
_setNewFilterState(props);
},
[subscriptionsCache?.data?.subscriptions]
);
const loadMoreButtonRef = useRef(null); const loadMoreButtonRef = useRef(null);
const { fetchMore, isFetchingMore, canFetchMore, EntriesPages, isLoading } = const { fetchMore, isFetchingMore, canFetchMore, EntriesPages, isLoading } =

Wyświetl plik

@ -7,7 +7,7 @@ const Scrollable = (props) => {
const [path, setPath] = useState(); const [path, setPath] = useState();
const [scrollDepth, setScrollDepth] = useState(0); const [scrollDepth, setScrollDepth] = useState(0);
const { mixpanel } = useAnalytics(); const { mixpanel, isLoaded } = useAnalytics();
const getScrollPrecent = ({ currentTarget }) => { const getScrollPrecent = ({ currentTarget }) => {
const scroll_level = const scroll_level =
@ -21,9 +21,10 @@ const Scrollable = (props) => {
if (currentScroll > scrollDepth) { if (currentScroll > scrollDepth) {
// withTracking( // withTracking(
setScrollDepth(currentScroll); setScrollDepth(currentScroll);
mixpanel.people.increment({ isLoaded &&
[`Scroll depth at: ${router.nextRouter.pathname}`]: currentScroll, mixpanel.people.increment({
}); [`Scroll depth at: ${router.nextRouter.pathname}`]: currentScroll,
});
} }
}; };

Wyświetl plik

@ -35,14 +35,6 @@ const AnalyticsProvider = ({ children }) => {
}, [isLoaded]); }, [isLoaded]);
useEffect(() => { useEffect(() => {
if (isLoaded) {
console.log(
"track:",
router.nextRouter.pathname,
router.query,
router.params
);
}
isLoaded && isLoaded &&
mixpanel.track(MIXPANEL_EVENTS.PAGEVIEW, { mixpanel.track(MIXPANEL_EVENTS.PAGEVIEW, {
url: router.nextRouter.pathname, url: router.nextRouter.pathname,