From 9515ceeb42e5ef5267400220a2082dec775e843d Mon Sep 17 00:00:00 2001 From: Matt Doyle <1092786+chief8192@users.noreply.github.com> Date: Mon, 23 Nov 2020 13:08:14 -0500 Subject: [PATCH] feat: automatically jump to the next photo when deleting while previewing (#1143) --- frontend/src/components/files/Preview.vue | 18 +++++++++++++++--- frontend/src/components/prompts/Delete.vue | 8 +++++--- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/frontend/src/components/files/Preview.vue b/frontend/src/components/files/Preview.vue index 1a8435b0..f72ad38b 100644 --- a/frontend/src/components/files/Preview.vue +++ b/frontend/src/components/files/Preview.vue @@ -133,16 +133,29 @@ export default { } }, async mounted () { - window.addEventListener('keyup', this.key) + window.addEventListener('keydown', this.key) this.$store.commit('setPreviewMode', true) this.listing = this.oldReq.items + this.$root.$on('preview-deleted', this.deleted) this.updatePreview() }, beforeDestroy () { - window.removeEventListener('keyup', this.key) + window.removeEventListener('keydown', this.key) this.$store.commit('setPreviewMode', false) + this.$root.$off('preview-deleted', this.deleted) }, methods: { + deleted () { + this.listing = this.listing.filter(item => item.name !== this.name) + + if (this.hasNext) { + this.next() + } else if (!this.hasPrevious && !this.hasNext) { + this.back() + } else { + this.prev() + } + }, back () { this.$store.commit('setPreviewMode', false) let uri = url.removeLastDir(this.$route.path) + '/' @@ -155,7 +168,6 @@ export default { this.$router.push({ path: this.nextLink }) }, key (event) { - event.preventDefault() if (this.show !== null) { return diff --git a/frontend/src/components/prompts/Delete.vue b/frontend/src/components/prompts/Delete.vue index 96ec85ad..67cbb33e 100644 --- a/frontend/src/components/prompts/Delete.vue +++ b/frontend/src/components/prompts/Delete.vue @@ -20,7 +20,6 @@