Skip to content

Commit

Permalink
fix(server): fixes storage route !'/u/userid'
Browse files Browse the repository at this point in the history
fixes #103
  • Loading branch information
roman-ojha committed Jun 9, 2022
1 parent a590889 commit 9a8c07b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
8 changes: 8 additions & 0 deletions client/src/components/ProfilePage/UserPosts.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { toastError } from "../../services/toast";
import {
setRootUserProfileDataState,
setRootUserPostData,
profilePageDataAction,
} from "../../services/redux-actions";

const UserPosts = (props) => {
Expand Down Expand Up @@ -35,6 +36,12 @@ const UserPosts = (props) => {
getRootUserProfileData: false,
})
);
const userObj = {
...userProfileDetailStore,
isRootUserFollowed: false,
posts: resPostData.posts,
};
dispatch(profilePageDataAction(userObj));
}
} catch (err) {
if (err.response) {
Expand All @@ -57,6 +64,7 @@ const UserPosts = (props) => {
dispatch,
props.profilePageData.userID,
rootUserProfileDataState,
userProfileDetailStore,
userProfileDetailStore.userID,
]);

Expand Down
2 changes: 2 additions & 0 deletions controllers/storage.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -335,9 +335,11 @@ export default {
},
likes: {
No: 0,
by: [],
},
comments: {
No: 0,
by: [],
},
};
const userStoryDetail = {
Expand Down
3 changes: 2 additions & 1 deletion models/userDetail_model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,8 @@ userDetailSchema.methods.uploadPost = async function (
},
{
$push: {
posts: postData,
// posts: postData,
posts: { $each: [postData], $position: 0 },
},
$inc: {
postNo: 1,
Expand Down
6 changes: 2 additions & 4 deletions routes/storageRoute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,13 @@ router.post(

router.post(
"/u/userId",
authenticate,
upload.single("profile"),
[authenticate, upload.single("profile")],
storageController.getUserID
);

router.post(
"/changeProfile/imgFile",
authenticate,
upload.single("image"),
[authenticate, upload.single("image")],
storageController.changeProfileUsingImgFile
);

Expand Down

0 comments on commit 9a8c07b

Please sign in to comment.