fix remove all drafts not deleting all drafts (lol)
This commit is contained in:
parent
d2545c6212
commit
eb1807351c
3 changed files with 13 additions and 11 deletions
|
|
@ -23,12 +23,7 @@ const Drafts = {
|
|||
this.showingConfirmDialog = true
|
||||
},
|
||||
doAbandonAll() {
|
||||
this.drafts.forEach((draft) => {
|
||||
this.$store.dispatch('abandonDraft', { id: draft.id }).then(() => {
|
||||
this.hideConfirmDialog()
|
||||
})
|
||||
})
|
||||
this.hideConfirmDialog()
|
||||
this.$store.dispatch('abandonAllDrafts').then(() => this.hideConfirmDialog())
|
||||
},
|
||||
hideConfirmDialog() {
|
||||
this.showingConfirmDialog = false
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@
|
|||
</div>
|
||||
</div>
|
||||
<teleport to="#modal">
|
||||
<confirm-modal
|
||||
<ConfirmModal
|
||||
v-if="showingConfirmDialog"
|
||||
:confirm-danger="true"
|
||||
:title="$t('drafts.abandon_confirm_title')"
|
||||
|
|
@ -47,7 +47,7 @@
|
|||
@cancelled="hideConfirmDialog"
|
||||
>
|
||||
{{ $t('drafts.abandon_all_confirm') }}
|
||||
</confirm-modal>
|
||||
</ConfirmModal>
|
||||
</teleport>
|
||||
</div>
|
||||
</template>
|
||||
|
|
|
|||
|
|
@ -42,9 +42,11 @@ const saveDraftToStorage = async (draft) => {
|
|||
await storage.setItem(storageKey, currentData)
|
||||
}
|
||||
|
||||
const deleteDraftFromStorage = async (id) => {
|
||||
const deleteDraftFromStorage = async (ids) => {
|
||||
const currentData = await getStorageData()
|
||||
delete currentData[id]
|
||||
ids.forEach(id => {
|
||||
delete currentData[id]
|
||||
})
|
||||
await storage.setItem(storageKey, currentData)
|
||||
}
|
||||
|
||||
|
|
@ -58,7 +60,12 @@ export const actions = {
|
|||
},
|
||||
async abandonDraft(store, { id }) {
|
||||
store.commit('abandonDraft', { id })
|
||||
await deleteDraftFromStorage(id)
|
||||
await deleteDraftFromStorage([id])
|
||||
},
|
||||
async abandonAllDrafts(store) {
|
||||
const ids = Object.keys(store.state.drafts)
|
||||
ids.forEach((id) => store.commit('abandonDraft', { id }))
|
||||
await deleteDraftFromStorage(ids)
|
||||
},
|
||||
async loadDrafts(store) {
|
||||
const currentData = await getStorageData()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue