Automatically jumps to the next photo when deleting while previewing.

This commit is contained in:
chief 2020-11-10 21:32:58 -05:00
parent dcbc3286e2
commit f8b5e869fd
2 changed files with 16 additions and 2 deletions

View File

@ -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) + '/'

View File

@ -20,7 +20,6 @@
<script>
import {mapGetters, mapMutations, mapState} from 'vuex'
import { files as api } from '@/api'
import url from '@/utils/url'
import buttons from '@/utils/buttons'
export default {
@ -39,7 +38,8 @@ export default {
if (!this.isListing) {
await api.remove(this.$route.path)
buttons.success('delete')
this.$router.push({ path: url.removeLastDir(this.$route.path) + '/' })
this.$root.$emit('preview_deleted', this.$route.path)
return
}