diff --git a/resources/js_vue3/stores/twofaccounts.js b/resources/js_vue3/stores/twofaccounts.js index 7588166f..a5d3be45 100644 --- a/resources/js_vue3/stores/twofaccounts.js +++ b/resources/js_vue3/stores/twofaccounts.js @@ -146,9 +146,12 @@ export const useTwofaccounts = defineStore({ if(confirm(trans('twofaccounts.confirm.delete')) && this.selectedIds.length > 0) { await twofaccountService.batchDelete(this.selectedIds.join()) .then(response => { - selectedIds.forEach(function(id) { - this.items = this.items.filter(a => a.id !== id) + let remainingItems = this.items + this.selectedIds.forEach(function(id) { + remainingItems = remainingItems.filter(a => a.id !== id) }) + this.items = remainingItems + this.selectNone() useNotifyStore().success({ text: trans('twofaccounts.accounts_deleted') }) }) } diff --git a/resources/js_vue3/views/twofaccounts/Accounts.vue b/resources/js_vue3/views/twofaccounts/Accounts.vue index 6c78cb50..a998822e 100644 --- a/resources/js_vue3/views/twofaccounts/Accounts.vue +++ b/resources/js_vue3/views/twofaccounts/Accounts.vue @@ -19,6 +19,7 @@ import { vDraggable } from 'vue-draggable-plus' const $2fauth = inject('2fauth') + const router = useRouter() const notify = useNotifyStore() const user = useUserStore() const bus = useBusStore() @@ -202,6 +203,17 @@ }) } + /** + * Deletes selected accounts + */ + async function deleteAccounts() { + await twofaccounts.deleteSelected() + + if (twofaccounts.isEmpty) { + router.push({ name: 'start' }) + } + } +