Skip to content

Commit

Permalink
Fix: isCreated가 true일 때는 임시저장 못하도록 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
dongree committed Oct 17, 2023
1 parent 27f9d7b commit 43157a1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/components/create/memo/EditorForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export default function EditorForm() {
const [tags, setTags] = useState<string[]>([]);
const [contents, setContents] = useState('');
const [isMemoLoading, setIsMemoLoading] = useState(false);
const [isCreated, setIsCreated] = useState(false);

const temporarySaveCallbackForSavingImage = async () => {
return createOrUpdateMemo(
Expand Down Expand Up @@ -130,11 +131,12 @@ export default function EditorForm() {
onCreate: async (e) => {
if (memoId)
await getMemoById(memoId).then(
({ memoTitle, memoColor, memoTags, memoText }) => {
({ memoTitle, memoColor, memoTags, memoText, isCreated }) => {
setTitle(memoTitle);
setSelectedColor(memoColor);
setTags(memoTags);
e.editor.commands.setContent(JSON.parse(memoText));
setIsCreated(isCreated);
}
);
setIsMemoLoading(true);
Expand Down Expand Up @@ -229,7 +231,8 @@ export default function EditorForm() {

// 자동 임시 저장
useEffect(() => {
if (!title || !temporaryContents || !contents || isLoading) return;
if (!title || !temporaryContents || !contents || isLoading || isCreated)
return;

const memoDescription = getDescription(contents);
createOrUpdateMemo(
Expand Down Expand Up @@ -345,12 +348,14 @@ export default function EditorForm() {
}`}
>
<div className="flex justify-end gap-2 mr-1 my-1">
<WhiteBtnWithCount
text="임시저장"
count={drafts.length}
onClickBtn={() => savePost('temporary')}
onClickCount={() => openDrafts(drafts)}
/>
{!isCreated && (
<WhiteBtnWithCount
text="임시저장"
count={drafts.length}
onClickBtn={() => savePost('temporary')}
onClickCount={() => openDrafts(drafts)}
/>
)}
<BlueBtn text="등록" onClick={() => savePost('permanent')} />
</div>
<input
Expand Down
1 change: 1 addition & 0 deletions src/types/memo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export type Memo = {
isTemporary: boolean;
isMine: boolean;
seriesId: number;
isCreated: boolean;
};

export type PostMemoData = {
Expand Down

0 comments on commit 43157a1

Please sign in to comment.