Skip to content

Commit

Permalink
fix: source/dav handling and delete event payload
Browse files Browse the repository at this point in the history
Signed-off-by: skjnldsv <skjnldsv@protonmail.com>

[skip ci]
  • Loading branch information
skjnldsv authored and backportbot[bot] committed Dec 4, 2024
1 parent 1790b9a commit 6e487db
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 13 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"@nextcloud/axios": "^2.5.0",
"@nextcloud/dialogs": "^5.3.7",
"@nextcloud/event-bus": "^3.3.1",
"@nextcloud/files": "^3.9.0",
"@nextcloud/files": "^3.10.0",
"@nextcloud/initial-state": "^2.2.0",
"@nextcloud/l10n": "^3.1.0",
"@nextcloud/logger": "^3.0.2",
Expand Down
26 changes: 18 additions & 8 deletions src/views/Viewer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@

<script>
import '@nextcloud/dialogs/style.css'
import Vue from 'vue'
import Vue, { defineComponent } from 'vue'

import axios from '@nextcloud/axios'
import { showError } from '@nextcloud/dialogs'
Expand Down Expand Up @@ -218,6 +218,7 @@ import Download from 'vue-material-design-icons/Download.vue'
import Fullscreen from 'vue-material-design-icons/Fullscreen.vue'
import FullscreenExit from 'vue-material-design-icons/FullscreenExit.vue'
import Pencil from 'vue-material-design-icons/Pencil.vue'
import { davGetRootPath } from '@nextcloud/files'

// Dynamic loading
const NcModal = () => import(
Expand All @@ -227,7 +228,7 @@ const NcModal = () => import(
const NcActionLink = () => import(/* webpackChunkName: 'components' */'@nextcloud/vue/dist/Components/NcActionLink.js')
const NcActionButton = () => import(/* webpackChunkName: 'components' */'@nextcloud/vue/dist/Components/NcActionButton.js')

export default {
export default defineComponent({
name: 'Viewer',

components: {
Expand Down Expand Up @@ -967,7 +968,7 @@ export default {
event.preventDefault()
if (this.canDownload) {
const a = document.createElement('a')
a.href = this.currentFile.davPath
a.href = this.currentFile.source ?? this.currentFile.davPath
a.download = this.currentFile.basename
document.body.appendChild(a)
a.click()
Expand Down Expand Up @@ -1120,16 +1121,25 @@ export default {
async onDelete() {
try {
const fileid = this.currentFile.fileid
const url = this.source ?? this.currentFile.davPath
const url = this.currentFile.source ?? this.currentFile.davPath

// Fake node to emit the event until Viewer is migrated to the new Node API.
const node = new NcFile({
source: url,
fileid,
mime: this.currentFile.mime,
owner: this.currentFile.ownerId,
root: url.includes('remote.php/dav') ? davGetRootPath() : undefined,
})

await axios.delete(url)
emit('files:node:deleted', { fileid })
emit('files:node:deleted', node)

// fileid is not unique, basename is not unqiue, filename is
// fileid is not unique, basename is not unique, filename is
const currentIndex = this.fileList.findIndex(file => file.filename === this.currentFile.filename)
if (this.hasPrevious || this.hasNext) {
// Checking the previous or next file
this.hasPrevious ? this.previous() : this.next()
this.hasNext ? this.next() : this.previous()

this.fileList.splice(currentIndex, 1)
} else {
Expand Down Expand Up @@ -1198,7 +1208,7 @@ export default {
},

},
}
})
</script>

<style lang="scss" scoped>
Expand Down

0 comments on commit 6e487db

Please sign in to comment.