From db33fe8ee252cc3944b7d4bb5527d8464cc19f81 Mon Sep 17 00:00:00 2001 From: solidsanek Date: Sun, 9 Apr 2023 11:02:13 +0200 Subject: [PATCH] Drafts: Fix drafts erasing edits and redrafts --- .../post_status_form/post_status_form.js | 48 ++++++++++--------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/src/components/post_status_form/post_status_form.js b/src/components/post_status_form/post_status_form.js index f7fef499..5647a9eb 100644 --- a/src/components/post_status_form/post_status_form.js +++ b/src/components/post_status_form/post_status_form.js @@ -169,31 +169,33 @@ const PostStatusForm = { } } - let draftKey = 'status'; - if (this.replyTo) { - draftKey = 'reply:' + this.replyTo; - } else if (this.quoteId) { - draftKey = 'quote:' + this.quoteId; - } - - const draft = JSON.parse(localStorage.getItem('drafts') || '{}')[draftKey]; - - if (draft) { - statusParams = { - spoilerText: draft.data.spoilerText, - status: draft.data.status, - sensitiveIfSubject, - nsfw: draft.data.nsfw, - files: draft.data.files, - poll: draft.data.poll, - mediaDescriptions: draft.data.mediaDescriptions, - visibility: draft.data.visibility, - language: draft.data.language, - contentType: draft.data.contentType + if (!this.statusId) { + let draftKey = 'status'; + if (this.replyTo) { + draftKey = 'reply:' + this.replyTo; + } else if (this.quoteId) { + draftKey = 'quote:' + this.quoteId; } - if (draft.data.poll) { - this.togglePollForm(); + const draft = JSON.parse(localStorage.getItem('drafts') || '{}')[draftKey]; + + if (draft) { + statusParams = { + spoilerText: draft.data.spoilerText, + status: draft.data.status, + sensitiveIfSubject, + nsfw: draft.data.nsfw, + files: draft.data.files, + poll: draft.data.poll, + mediaDescriptions: draft.data.mediaDescriptions, + visibility: draft.data.visibility, + language: draft.data.language, + contentType: draft.data.contentType + } + + if (draft.data.poll) { + this.togglePollForm(); + } } }