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

Commit

Permalink
Merge pull request #134 from Sebastian-Webster/history-viewer-fails-t…
Browse files Browse the repository at this point in the history
…o-load-for-posts-with-users-who-dont-have-profile-pictures

fix history viewer failing to load when post creator doesn't have profile picture
  • Loading branch information
Sebastian-Webster authored Sep 25, 2022
2 parents 46cfee9 + b91bf5b commit ba13ea3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion backend/models/User.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/routes/HistoryViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit ba13ea3

Please sign in to comment.