Skip to content

Commit 82f39a4

Browse files
skjnldsvbackportbot[bot]
authored andcommitted
fix: source/dav handling and delete event payload
Signed-off-by: skjnldsv <skjnldsv@protonmail.com> [skip ci]
1 parent 6cf7686 commit 82f39a4

3 files changed

Lines changed: 19 additions & 10 deletions

File tree

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"@nextcloud/axios": "^2.5.0",
4747
"@nextcloud/dialogs": "^5.3.7",
4848
"@nextcloud/event-bus": "^3.3.1",
49-
"@nextcloud/files": "^3.9.0",
49+
"@nextcloud/files": "^3.10.0",
5050
"@nextcloud/initial-state": "^2.2.0",
5151
"@nextcloud/l10n": "^3.1.0",
5252
"@nextcloud/logger": "^2.7.0",

src/views/Viewer.vue

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@
188188

189189
<script>
190190
import '@nextcloud/dialogs/style.css'
191-
import Vue from 'vue'
191+
import Vue, { defineComponent } from 'vue'
192192
193193
import axios from '@nextcloud/axios'
194194
import { showError } from '@nextcloud/dialogs'
@@ -225,7 +225,7 @@ const NcModal = () => import(
225225
const NcActionLink = () => import(/* webpackChunkName: 'components' */'@nextcloud/vue/dist/Components/NcActionLink.js')
226226
const NcActionButton = () => import(/* webpackChunkName: 'components' */'@nextcloud/vue/dist/Components/NcActionButton.js')
227227
228-
export default {
228+
export default defineComponent({
229229
name: 'Viewer',
230230
231231
components: {
@@ -963,7 +963,7 @@ export default {
963963
event.preventDefault()
964964
if (this.canDownload) {
965965
const a = document.createElement('a')
966-
a.href = this.currentFile.davPath
966+
a.href = this.currentFile.source ?? this.currentFile.davPath
967967
a.download = this.currentFile.basename
968968
document.body.appendChild(a)
969969
a.click()
@@ -1116,16 +1116,25 @@ export default {
11161116
async onDelete() {
11171117
try {
11181118
const fileid = this.currentFile.fileid
1119-
const url = this.source ?? this.currentFile.davPath
1119+
const url = this.currentFile.source ?? this.currentFile.davPath
1120+
1121+
// Fake node to emit the event until Viewer is migrated to the new Node API.
1122+
const node = new NcFile({
1123+
source: url,
1124+
fileid,
1125+
mime: this.currentFile.mime,
1126+
owner: this.currentFile.ownerId,
1127+
root: url.includes('remote.php/dav') ? davGetRootPath() : undefined,
1128+
})
11201129
11211130
await axios.delete(url)
1122-
emit('files:node:deleted', { fileid })
1131+
emit('files:node:deleted', node)
11231132
1124-
// fileid is not unique, basename is not unqiue, filename is
1133+
// fileid is not unique, basename is not unique, filename is
11251134
const currentIndex = this.fileList.findIndex(file => file.filename === this.currentFile.filename)
11261135
if (this.hasPrevious || this.hasNext) {
11271136
// Checking the previous or next file
1128-
this.hasPrevious ? this.previous() : this.next()
1137+
this.hasNext ? this.next() : this.previous()
11291138
11301139
this.fileList.splice(currentIndex, 1)
11311140
} else {
@@ -1194,7 +1203,7 @@ export default {
11941203
},
11951204
11961205
},
1197-
}
1206+
})
11981207
</script>
11991208
12001209
<style lang="scss" scoped>

0 commit comments

Comments
 (0)