From f8b5e869fde8e0509b5fc06ec895d4dfc66632ef Mon Sep 17 00:00:00 2001 From: chief <1092786+chief8192@users.noreply.github.com> Date: Tue, 10 Nov 2020 21:32:58 -0500 Subject: [PATCH] Automatically jumps to the next photo when deleting while previewing. --- frontend/src/components/files/Preview.vue | 14 ++++++++++++++ frontend/src/components/prompts/Delete.vue | 4 ++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/files/Preview.vue b/frontend/src/components/files/Preview.vue index 1a8435b0..e5b99877 100644 --- a/frontend/src/components/files/Preview.vue +++ b/frontend/src/components/files/Preview.vue @@ -136,6 +136,7 @@ export default { window.addEventListener('keyup', this.key) this.$store.commit('setPreviewMode', true) this.listing = this.oldReq.items + this.$root.$on('preview_deleted', this.deleted) this.updatePreview() }, beforeDestroy () { @@ -143,6 +144,19 @@ export default { this.$store.commit('setPreviewMode', false) }, methods: { + deleted (path) { + + let pieces = path.split('/') + let deletedName = decodeURIComponent(pieces[pieces.length - 1]) + + this.listing = this.listing.filter(item => item.name !== deletedName) + + if (this.hasNext) { + this.next() + } else { + this.back() + } + }, back () { this.$store.commit('setPreviewMode', false) let uri = url.removeLastDir(this.$route.path) + '/' diff --git a/frontend/src/components/prompts/Delete.vue b/frontend/src/components/prompts/Delete.vue index 96ec85ad..18fc18a1 100644 --- a/frontend/src/components/prompts/Delete.vue +++ b/frontend/src/components/prompts/Delete.vue @@ -20,7 +20,6 @@