Skip to content

Commit

Permalink
fix: missing loading animation
Browse files Browse the repository at this point in the history
  • Loading branch information
emberist committed Sep 21, 2022
1 parent 3dbb2f7 commit 0b2b27e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
18 changes: 9 additions & 9 deletions src/components/common/Loader/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import ClipLoader from "react-spinners/ClipLoader";
import { Flex } from "~/components/common/Flex";
import { Text } from "~/components/common/Text";
import { colors } from "~/utils/colors";

const messages = [
"Searching Podcast Index",
"Searching YouTube",
Expand All @@ -18,16 +17,17 @@ export const Loader = () => {
const [msgIndex, setMsgIndex] = useState(0);

useEffect(() => {
const messageTimeout = setTimeout(doIndex, 5000);
if (msgIndex === messages.length - 1) {
return;
}

return function cleanup() {
clearTimeout(messageTimeout);
};
}, [msgIndex]);
const messageTimeout = setTimeout(
() => setMsgIndex((index) => (index + 1) % messages.length),
1000
);

function doIndex() {
if (msgIndex < messages.length - 1) setMsgIndex(msgIndex + 1);
}
return () => clearTimeout(messageTimeout);
}, [msgIndex]);

return (
<Flex grow={1} align="center" justify="center">
Expand Down
2 changes: 0 additions & 2 deletions src/stores/useDataStore/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ type DataStore = {
selectedNode: NodeExtended | null;
selectedTimestamp: NodeExtended | null;
setCameraAnimation: (cameraAnimation: gsap.core.Tween | null) => void;
setLoadingData: (bool: boolean) => void;
fetchData: (search?: string | null) => void;
setSelectedNode: (selectedNode: NodeExtended | null) => void;
setSelectedTimestamp: (selectedTimestamp: NodeExtended | null) => void;
Expand All @@ -29,7 +28,6 @@ export const useDataStore = create<DataStore>((set, get) => ({
selectedNode: null,
selectedTimestamp: null,
setCameraAnimation: (cameraAnimation) => set({ cameraAnimation }),
setLoadingData: (isFetching) => set({ isFetching }),
setHoveredNode: (hoveredNode) => set({ hoveredNode }),
setSelectedNode: (selectedNode) =>
set({ selectedNode, isTimestampLoaded: false }),
Expand Down

0 comments on commit 0b2b27e

Please sign in to comment.