Skip to content
This repository was archived by the owner on Oct 22, 2024. It is now read-only.

Commit 4597bf1

Browse files
change storedCredentials to deal with int followers instead of an array of followers
1 parent 653b20c commit 4597bf1

File tree

4 files changed

+12
-10
lines changed

4 files changed

+12
-10
lines changed

backend/controllers/User.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ const login = async (req, res) => {
6060
http.OK(res, 'Successfully logged in', {
6161
email: LoginResponse.email,
6262
name: LoginResponse.name,
63-
followers: LoginResponse.followers,
64-
following: LoginResponse.following,
63+
followers: LoginResponse.followers.length,
64+
following: LoginResponse.following.length,
6565
_id: LoginResponse._id,
6666
profileImageKey: LoginResponse.profileImageKey,
6767
publicId: LoginResponse.publicId
@@ -186,8 +186,8 @@ const signup = async (req, res) => {
186186
const toSend = {
187187
name: newUserResponse.name,
188188
email: newUserResponse.email,
189-
followers: newUserResponse.followers,
190-
following: newUserResponse.following,
189+
followers: newUserResponse.followers.length,
190+
following: newUserResponse.following.length,
191191
_id: newUserResponse._id,
192192
publicId: newUserResponse.publicId
193193
}

frontend/src/routes/Home.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const Home = () => {
66
const {following} = storedCredentials;
77
return (
88
<div style={{display: 'flex', justifyContent: 'center', alignItems: 'center', flexDirection: 'column'}}>
9-
{following.length > 0 ?
9+
{following > 0 ?
1010
<h1>Home feed coming soon</h1>
1111
:
1212
<h1>Start following some people to see a home feed! - Home feed coming soon</h1>

frontend/src/routes/Profile.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { ServerUrlContext } from '../context/ServerUrlContext';
1717
import useColorScheme from '../hooks/useColorScheme';
1818
import { useParams, useNavigate } from 'react-router-dom';
1919
import FollowButton from '../components/FollowButton';
20+
import { ExtraFollowersContext } from '../context/ExtraFollowersContext';
2021

2122
var _ = require('lodash')
2223

@@ -38,10 +39,10 @@ const Profile = () => {
3839
const [isFollowing, setIsFollowing] = useState(null)
3940
const navigate = useNavigate()
4041

41-
//Set to followers.length if you are visitng your own profile page via the profile button.
42-
//Set to followers.length if you are visitng your own profile page via the search page.
42+
//Set to followers if you are visitng your own profile page via the profile button.
43+
//Set to followers if you are visitng your own profile page via the search page.
4344
//Set to 0 if you are visiting someone else's profile as loadPublicProfileInformation() will get the amount of followers and set followerNumber to that.
44-
const [followerNumber, setFollowerNumber] = useState(profilePublicId ? profilePublicId === publicId ? followers.length : 0 : followers.length)
45+
const [followerNumber, setFollowerNumber] = useState(profilePublicId ? profilePublicId === publicId ? followers : 0 : followers)
4546

4647
useEffect(() => {
4748
setFollowerNumber(
@@ -60,7 +61,7 @@ const Profile = () => {
6061
:
6162
profileData.followers
6263
: //If you are visiting your own profile from the profile screen
63-
followers.length
64+
followers
6465
)
6566
}, [profilePublicId, profileData, isFollowing])
6667

@@ -549,7 +550,7 @@ const Profile = () => {
549550
<H3NoMargin>{followerNumber === 1 ? 'Follower' : 'Followers'}</H3NoMargin>
550551
</FlexColumnCentreDiv>
551552
<FlexColumnCentreDiv style={{cursor: 'pointer'}} onClick={() => profilePublicId && profilePublicId !== publicId ? navigate(`/following/${profilePublicId}/${profileData.name}`) : navigate('/following')}>
552-
<H3NoMargin>{profilePublicId ? profileData.following : following.length}</H3NoMargin>
553+
<H3NoMargin>{profilePublicId ? profileData.following : following}</H3NoMargin>
553554
<H3NoMargin>Following</H3NoMargin>
554555
{profilePublicId && profileData.isFollower && <H3NoMargin>({profileData.name} follows you)</H3NoMargin>}
555556
</FlexColumnCentreDiv>

frontend/src/routes/Signup.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ const Signup = () => {
4646
result.profileImageUri = defaultPfp
4747
setLoading(false)
4848
setStoredCredentials(result)
49+
result.rememberMe = true;
4950
if (rememberMe) localStorage.setItem('SebMediaCredentials', JSON.stringify(result))
5051
navigate('/home')
5152
}).catch(error => {

0 commit comments

Comments
 (0)