From b91bf5b18d7e34b3d6956de09a433a7c88c8e21c Mon Sep 17 00:00:00 2001 From: Sebastian Webster Date: Sun, 25 Sep 2022 20:51:53 +1300 Subject: [PATCH] fix history viewer failing to load when post creator doesn't have profile picture --- backend/models/User.js | 2 +- frontend/src/routes/HistoryViewer.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/models/User.js b/backend/models/User.js index e14471e..3fc2043 100644 --- a/backend/models/User.js +++ b/backend/models/User.js @@ -7,7 +7,7 @@ const UserSchema = new Schema({ password: String, followers: Array, following: Array, - profileImageKey: String, + profileImageKey: {type: String, default: ''}, publicId: String, hideFollowing: {type: Boolean, default: false}, hideFollowers: {type: Boolean, default: false} diff --git a/frontend/src/routes/HistoryViewer.js b/frontend/src/routes/HistoryViewer.js index 500c436..d97eed9 100644 --- a/frontend/src/routes/HistoryViewer.js +++ b/frontend/src/routes/HistoryViewer.js @@ -39,7 +39,7 @@ const HistoryViewer = () => { const {profileData, editHistory, currentPost} = result; if (currentPost.imageKey) currentPost.image = ('data:image/jpeg;base64,' + (await axios.get(`${serverUrl}/image/${currentPost.imageKey}`)).data) - profileData.profilePicture = profileData.profileImageKey !== '' ? ('data:image/jpeg;base64,' + (await axios.get(`${serverUrl}/image/${profileData.profileImageKey}`)).data) : defaultPfp + profileData.profilePicture = profileData?.profileImageKey && profileData?.profileImageKey !== '' ? ('data:image/jpeg;base64,' + (await axios.get(`${serverUrl}/image/${profileData.profileImageKey}`)).data) : defaultPfp setCurrentPost(currentPost) setEditHistory(editHistory.sort((a,b) => b.dateMade - a.dateMade)) setProfileData(profileData)