Skip to content

Commit afe28f3

Browse files
#TRAPWLS-19 code optimized
1 parent 760e579 commit afe28f3

File tree

3 files changed

+19
-14
lines changed

3 files changed

+19
-14
lines changed

src/homePage/Card.jsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,15 @@ const Card = ({post, itemArrLength, isAllCardLoaded}) => {
1010

1111
useEffect(() => {
1212
counter = counter + 1;
13-
if (itemArrLength === counter) {
14-
return () => {
15-
setTimeout(() => { isAllCardLoaded(true) }, 1000);
16-
};
17-
}
13+
const timer = setTimeout(() => {
14+
if (itemArrLength === counter) {
15+
isAllCardLoaded(true)
16+
}
17+
}, 1000);
18+
return () => {
19+
clearTimeout(timer);
20+
counter = 0;
21+
};
1822
}, [itemArrLength, isAllCardLoaded]);
1923

2024
return (

src/homePage/Footer.jsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
import React from "react";
2-
import { BrowserRouter, Routes, Route} from 'react-router-dom';
32
import {
43
Box,
54
Container,
65
Row,
76
Column,
87
FooterLink,
9-
Heading,
108
} from "./Footerstyle";
11-
import { Outlet, Link} from "react-router-dom";
129

1310
function Footer() {
1411
return (

src/homePage/HeaderNavbarLogin.jsx

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React, { useEffect, useState } from 'react'
22
import { Link, NavLink, useNavigate } from 'react-router-dom'
33
import "../App.css"
44
import { auth } from '../loginAuthentication/firebase/FirebaseConfig';
5-
import { signOut, deleteUser } from "firebase/auth";
5+
import { deleteUser } from "firebase/auth";
66
import ClipLoader from 'react-spinners/ClipLoader';
77

88
// SampleProfileUrl - https://images.pexels.com/photos/1742370/pexels-photo-1742370.jpeg?auto=compress&cs=tinysrgb&dpr=2&w=500
@@ -19,18 +19,22 @@ const HeaderNavbarLogin = (props) => {
1919
if(loggedInData?.loggedInType === "usernamePwd") {
2020
await auth.signOut();
2121
} else {
22-
signOut(auth).then(() => {
22+
try {
23+
await auth.signOut();
2324
if (user) {
24-
deleteUser(user);
25+
await deleteUser(user);
2526
console.log("User successfully deleted from Firebase.");
2627
}
28+
29+
} catch(exception) {
30+
console.error("Sign out error-->",exception)
2731
setIsLoading(false);
28-
}).catch((e) => {
29-
console.error("Sign out error-->",e)
30-
})
32+
return;
33+
}
3134
}
3235

3336
localStorage.removeItem("loggedInData");
37+
setIsLoading(false);
3438
setLoggedInUser(false);
3539
navigateToNextPage("/");
3640
return;

0 commit comments

Comments
 (0)