fixed some bugs

This commit is contained in:
Ren Amamiya
2023-03-10 09:30:13 +07:00
parent 42f4c8339e
commit c77c08675a
11 changed files with 269 additions and 251 deletions

View File

@@ -5,26 +5,32 @@ import LumeSymbol from '@assets/icons/Lume';
import { useLocalStorage } from '@rehooks/local-storage';
import { motion } from 'framer-motion';
import { useRouter } from 'next/router';
import { JSXElementConstructor, ReactElement, ReactFragment, ReactPortal, useEffect, useState } from 'react';
import { JSXElementConstructor, ReactElement, ReactFragment, ReactPortal, useEffect, useRef, useState } from 'react';
export default function Page() {
const router = useRouter();
const [currentUser]: any = useLocalStorage('current-user');
const [loading, setLoading] = useState(true);
const timer = useRef(null);
useEffect(() => {
if (!currentUser) {
setTimeout(() => {
setLoading(false);
router.push('/onboarding');
}, 1500);
} else {
setTimeout(() => {
if (currentUser) {
timer.current = setTimeout(() => {
setLoading(false);
router.push('/newsfeed/following');
}, 1500);
}, 1000);
} else {
timer.current = setTimeout(() => {
setLoading(false);
router.push('/onboarding');
}, 1000);
}
// clean up
return () => {
clearTimeout(timer.current);
};
}, [currentUser, router]);
return (