Skip to content

Commit 0fc434a

Browse files
better post uploading response
1 parent 9d20a82 commit 0fc434a

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

client/src/components/layout components/editor/PostEditor.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const PostEditor = ({
2121
}) => {
2222
const [heading, setHeading] = useState("");
2323
const [upload, setUpload] = useState("");
24+
const [uploadingContent, setUploadingContent] = useState(false);
2425
const [editorState, setEditorState] = useState(() =>
2526
EditorState.createEmpty()
2627
);
@@ -32,6 +33,13 @@ const PostEditor = ({
3233
}
3334
}, [post.imageUploaded]);
3435

36+
useEffect(() => {
37+
if (post.uploadedStatus) {
38+
setUploadingContent(false);
39+
history.push("/");
40+
}
41+
}, [post.uploadedStatus]);
42+
3543
useEffect(() => {
3644
if (upload === "Uploaded!") {
3745
dispatchPopup("Post Image", "Post image has been uploaded successfully!");
@@ -43,6 +51,7 @@ const PostEditor = ({
4351
const postRawContent = convertToRaw(editorState.getCurrentContent())
4452
.blocks;
4553
if (heading !== "" && post.postID !== undefined) {
54+
setUploadingContent(true);
4655
uploadPost(
4756
{
4857
heading: heading,
@@ -52,7 +61,6 @@ const PostEditor = ({
5261
);
5362
}
5463
clearPostID();
55-
history.push("/");
5664
}
5765
};
5866

@@ -119,8 +127,8 @@ const PostEditor = ({
119127
/>
120128
</EditorWrapper>
121129
</S.Box>
122-
<S.Button w="250px" onClick={handleSave}>
123-
<S.Text>{post.uploadedStatus ? "" : "Post"}</S.Text>
130+
<S.Button w="250px" onClick={handleSave} isLoading={uploadingContent}>
131+
<S.Text>Post</S.Text>
124132
</S.Button>
125133
</S.Flex>
126134
);

0 commit comments

Comments
 (0)