diff --git a/src/components/draft/draft.js b/src/components/draft/draft.js
index 12df0d651..90497139b 100644
--- a/src/components/draft/draft.js
+++ b/src/components/draft/draft.js
@@ -36,6 +36,7 @@ const Draft = {
return {
referenceDraft: cloneDeep(this.draft),
editing: false,
+ showingForm: false,
showingConfirmDialog: false,
}
},
@@ -52,7 +53,7 @@ const Draft = {
}
},
safeToSave() {
- return (
+ return Boolean(
this.draft.status ||
this.draft.files?.length ||
this.draft.hasPoll ||
@@ -76,14 +77,9 @@ const Draft = {
},
watch: {
editing(newVal) {
- console.log('SAVE?', newVal)
+ this.showingForm = true
if (newVal) return
- console.log('SAVE', newVal)
- if (this.safeToSave) {
- useDraftsStore().addOrSaveDraft(this.draft)
- } else {
- useDraftsStore().addOrSaveDraft(this.referenceDraft)
- }
+ this.showingForm = false
},
},
methods: {
diff --git a/src/components/draft/draft.vue b/src/components/draft/draft.vue
index e610f627b..1fc0294e6 100644
--- a/src/components/draft/draft.vue
+++ b/src/components/draft/draft.vue
@@ -64,14 +64,16 @@
-
+
diff --git a/src/components/post_status_form/post_status_form.js b/src/components/post_status_form/post_status_form.js
index b708d3f68..ed48de2d7 100644
--- a/src/components/post_status_form/post_status_form.js
+++ b/src/components/post_status_form/post_status_form.js
@@ -987,6 +987,8 @@ const PostStatusForm = {
type: this.statusType,
refId: this.refId,
...this.newStatus,
+ // Draft ID overwrites status ID (which is undefined for fresh statuses)
+ id: this.draftId,
})
.then((id) => {
if (this.newStatus.id !== id) {
diff --git a/src/stores/drafts.js b/src/stores/drafts.js
index 0f3fae527..bf707cbe4 100644
--- a/src/stores/drafts.js
+++ b/src/stores/drafts.js
@@ -62,14 +62,13 @@ export const useDraftsStore = defineStore('drafts', {
},
async addOrSaveDraft(draft) {
const id = draft.id ?? new Date().getTime().toString()
- console.log('SAVE', id)
const draftWithId = { ...draft, id }
- this.drafts.set(draft.id, draftWithId)
+ this.drafts.set(id, draftWithId)
await saveDraftToStorage(draftWithId)
return id
},
async abandonAllDrafts(store) {
- const ids = this.drafts.keys()
+ const ids = [...this.drafts.keys()]
ids.forEach((id) => this.abandonDraft(id))
await deleteDraftFromStorage(ids)
},