Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions js/viewer-main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/viewer-main.js.map

Large diffs are not rendered by default.

21 changes: 15 additions & 6 deletions src/views/Viewer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@
:data-handler="handlerId"
:enable-slideshow="hasPrevious || hasNext"
:enable-swipe="canSwipe && !editing"
:has-next="hasNext && (canLoop ? true : !isEndOfList)"
:has-previous="hasPrevious && (canLoop ? true : !isStartOfList)"
:has-next="hasNext"
:has-previous="hasPrevious"
:inline-actions="canEdit ? 1 : 0"
:spread-navigation="true"
:style="{ width: isSidebarShown ? `calc(100% - ${sidebarWidth}px)` : null }"
Expand Down Expand Up @@ -153,7 +153,7 @@ import Vue from 'vue'
import axios from '@nextcloud/axios'
import '@nextcloud/dialogs/styles/toast.scss'
import { showError } from '@nextcloud/dialogs'
import { subscribe, unsubscribe } from '@nextcloud/event-bus'
import { emit, subscribe, unsubscribe } from '@nextcloud/event-bus'

import NcActionButton from '@nextcloud/vue/dist/Components/NcActionButton.js'
import NcActionLink from '@nextcloud/vue/dist/Components/NcActionLink.js'
Expand Down Expand Up @@ -237,9 +237,11 @@ export default {
},
hasPrevious() {
return this.fileList.length > 1
&& (this.canLoop || !this.isStartOfList)
},
hasNext() {
return this.fileList.length > 1
&& (this.canLoop || !this.isEndOfList)
},
file() {
return this.Viewer.file
Expand All @@ -257,7 +259,7 @@ export default {
return this.Viewer.loadMore
},
canLoop() {
return this.Viewer.canLoop
return false
},
canZoom() {
return !this.Viewer.el
Expand Down Expand Up @@ -937,10 +939,17 @@ export default {

async onDelete() {
try {
const fileid = this.currentFile.fileid
const url = this.source ?? this.root + this.currentFile.filename

await axios.delete(url)
if (this.hasPrevious) {
this.previous()
emit('files:file:deleted', { fileid })

if (this.hasPrevious || this.hasNext) {
// Checking the previous or next file
this.hasPrevious ? this.previous() : this.next()

// fileid is not unique, basename is
const currentIndex = this.fileList.findIndex(file => file.basename === this.currentFile.basename)
this.fileList.splice(currentIndex, 1)
} else {
Expand Down