Skip to content

Commit ce7d2e8

Browse files
committed
feat: Dont ask to load draft if the current draft has not been cleared from the editor
1 parent a0f0889 commit ce7d2e8

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/components/layout/Editor.vue

+7-6
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ export default {
267267
v.threadCopy.pollValid = valid
268268
v.threadCopy.poll = poll
269269
}
270+
270271
const saveDraft = clear => {
271272
if (v.editMode || v.quoteMode) return
272273
let rawText = v.posting.post.body || v.threadCopy.body || v.newMessage.content.body
@@ -292,21 +293,22 @@ export default {
292293
}
293294
}
294295
295-
const loadDraft = () => {
296+
const loadDraft = (postBody) => {
296297
if (v.editMode || v.quoteMode) return
297298
let draftPromise
298299
if (props.postEditorMode || props.threadEditorMode) {
299300
draftPromise = postsApi.getPostDraft
300301
}
301302
else draftPromise = messagesApi.getMessageDraft
302303
draftPromise().then(data => {
303-
if (data.draft && confirm('Load Draft?')) {
304+
if (data.draft && !postBody && confirm('Load Draft?')) {
304305
if (props.postEditorMode) v.posting.post.body = data.draft
305306
else if (props.threadEditorMode) v.threadCopy.body = data.draft
306307
else v.newMessage.content.body = data.draft
307308
}
308-
});
309-
};
309+
else if (data.draft && postBody !== data.draft && props.postEditorMode && confirm('Load Draft?')) v.posting.post.body = data.draft
310+
})
311+
}
310312
311313
/* View Data */
312314
const v = reactive({
@@ -389,9 +391,8 @@ export default {
389391
else nextTick(() => v.messageEditorEl.focus())
390392
}
391393
nextTick(() => {
392-
console.log(v.quoteMode, v.editMode)
393394
if (visible && !v.editMode && !v.quoteMode) {
394-
loadDraft()
395+
loadDraft(v.posting?.post?.body)
395396
saveDraft()
396397
}
397398
else {

0 commit comments

Comments
 (0)