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
|
this.showingConfirmDialog = true
|
||||||
},
|
},
|
||||||
doAbandonAll() {
|
doAbandonAll() {
|
||||||
this.drafts.forEach((draft) => {
|
this.$store.dispatch('abandonAllDrafts').then(() => this.hideConfirmDialog())
|
||||||
this.$store.dispatch('abandonDraft', { id: draft.id }).then(() => {
|
|
||||||
this.hideConfirmDialog()
|
|
||||||
})
|
|
||||||
})
|
|
||||||
this.hideConfirmDialog()
|
|
||||||
},
|
},
|
||||||
hideConfirmDialog() {
|
hideConfirmDialog() {
|
||||||
this.showingConfirmDialog = false
|
this.showingConfirmDialog = false
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<teleport to="#modal">
|
<teleport to="#modal">
|
||||||
<confirm-modal
|
<ConfirmModal
|
||||||
v-if="showingConfirmDialog"
|
v-if="showingConfirmDialog"
|
||||||
:confirm-danger="true"
|
:confirm-danger="true"
|
||||||
:title="$t('drafts.abandon_confirm_title')"
|
:title="$t('drafts.abandon_confirm_title')"
|
||||||
|
|
@ -47,7 +47,7 @@
|
||||||
@cancelled="hideConfirmDialog"
|
@cancelled="hideConfirmDialog"
|
||||||
>
|
>
|
||||||
{{ $t('drafts.abandon_all_confirm') }}
|
{{ $t('drafts.abandon_all_confirm') }}
|
||||||
</confirm-modal>
|
</ConfirmModal>
|
||||||
</teleport>
|
</teleport>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
||||||
|
|
@ -42,9 +42,11 @@ const saveDraftToStorage = async (draft) => {
|
||||||
await storage.setItem(storageKey, currentData)
|
await storage.setItem(storageKey, currentData)
|
||||||
}
|
}
|
||||||
|
|
||||||
const deleteDraftFromStorage = async (id) => {
|
const deleteDraftFromStorage = async (ids) => {
|
||||||
const currentData = await getStorageData()
|
const currentData = await getStorageData()
|
||||||
delete currentData[id]
|
ids.forEach(id => {
|
||||||
|
delete currentData[id]
|
||||||
|
})
|
||||||
await storage.setItem(storageKey, currentData)
|
await storage.setItem(storageKey, currentData)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -58,7 +60,12 @@ export const actions = {
|
||||||
},
|
},
|
||||||
async abandonDraft(store, { id }) {
|
async abandonDraft(store, { id }) {
|
||||||
store.commit('abandonDraft', { 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) {
|
async loadDrafts(store) {
|
||||||
const currentData = await getStorageData()
|
const currentData = await getStorageData()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue