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

Commit ba13ea3

Browse files
Merge pull request #134 from Sebastian-Webster/history-viewer-fails-to-load-for-posts-with-users-who-dont-have-profile-pictures
fix history viewer failing to load when post creator doesn't have profile picture
2 parents 46cfee9 + b91bf5b commit ba13ea3

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

backend/models/User.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const UserSchema = new Schema({
77
password: String,
88
followers: Array,
99
following: Array,
10-
profileImageKey: String,
10+
profileImageKey: {type: String, default: ''},
1111
publicId: String,
1212
hideFollowing: {type: Boolean, default: false},
1313
hideFollowers: {type: Boolean, default: false}

frontend/src/routes/HistoryViewer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const HistoryViewer = () => {
3939
const {profileData, editHistory, currentPost} = result;
4040

4141
if (currentPost.imageKey) currentPost.image = ('data:image/jpeg;base64,' + (await axios.get(`${serverUrl}/image/${currentPost.imageKey}`)).data)
42-
profileData.profilePicture = profileData.profileImageKey !== '' ? ('data:image/jpeg;base64,' + (await axios.get(`${serverUrl}/image/${profileData.profileImageKey}`)).data) : defaultPfp
42+
profileData.profilePicture = profileData?.profileImageKey && profileData?.profileImageKey !== '' ? ('data:image/jpeg;base64,' + (await axios.get(`${serverUrl}/image/${profileData.profileImageKey}`)).data) : defaultPfp
4343
setCurrentPost(currentPost)
4444
setEditHistory(editHistory.sort((a,b) => b.dateMade - a.dateMade))
4545
setProfileData(profileData)

0 commit comments

Comments
 (0)