Skip to content

Commit 78902f9

Browse files
committed
fix: duplicated image upload bug
1 parent 56f67c8 commit 78902f9

File tree

4 files changed

+4
-8
lines changed

4 files changed

+4
-8
lines changed

src/containers/write/MarkdownEditorContainer.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ const MarkdownEditorContainer: React.FC<MarkdownEditorContainerProps> = () => {
214214
if (shallowEqual(lastSavedData, { title, body: markdown })) {
215215
return;
216216
}
217+
217218
if (postId) {
218219
await createPostHistory({
219220
variables: {
@@ -224,6 +225,7 @@ const MarkdownEditorContainer: React.FC<MarkdownEditorContainerProps> = () => {
224225
},
225226
});
226227
}
228+
227229
setLastSavedData({
228230
title,
229231
body: markdown,
@@ -255,7 +257,6 @@ const MarkdownEditorContainer: React.FC<MarkdownEditorContainerProps> = () => {
255257
const uploadWithPostId = useCallback(
256258
async (file: File) => {
257259
if (!file) return;
258-
if (writePostLoading || editPostLoading) return;
259260
let id = postIdRef.current;
260261
if (!id) {
261262
const title = titleRef.current || 'Temp Title';
@@ -291,7 +292,7 @@ const MarkdownEditorContainer: React.FC<MarkdownEditorContainerProps> = () => {
291292
toast.error('이미지 업로드 실패! 잠시 후 다시 시도하세요.');
292293
});
293294
},
294-
[cfUpload, writePost, dispatch, history, writePostLoading, editPostLoading],
295+
[cfUpload, writePost, dispatch, history],
295296
);
296297

297298
const onDragDropUpload = useCallback(

src/containers/write/PublishPreviewContainer.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ const PublishPreviewContainer: React.FC<PublishPreviewContainerProps> = ({
114114

115115
useEffect(() => {
116116
if (!file) return;
117-
if (writePostLoading) return;
118117
uploadWithPostId(file);
119118
// eslint-disable-next-line react-hooks/exhaustive-deps
120119
}, [file, writePostLoading]);

src/lib/api/files.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,7 @@ export async function uploadImage(
3535
headers: {
3636
'Content-Type': 'multipart/form-data',
3737
},
38-
onUploadProgress(e) {
39-
console.log(e);
40-
},
38+
onUploadProgress(event) {},
4139
},
4240
);
4341

src/lib/hooks/useUpload.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ const useUpload = () => {
1111
input.type = 'file';
1212
input.onchange = () => {
1313
clearTimeout(timeout);
14-
console.log('onchange');
15-
console.log(input.files);
1614
if (!input.files) return reject();
1715
const file = input.files[0];
1816
setFile(file);

0 commit comments

Comments
 (0)