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 <[email protected]>
  • Loading branch information
skjnldsv committed Nov 21, 2024
1 parent 02d749e commit 67647c4
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 14 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.1",
"@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
28 changes: 19 additions & 9 deletions src/views/Viewer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,11 @@

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

import { emit, subscribe, unsubscribe } from '@nextcloud/event-bus'
import { loadState } from '@nextcloud/initial-state'
import { Node, davRemoteURL, davRootPath } from '@nextcloud/files'
import { File as NcFile, Node, davRemoteURL, davRootPath } from '@nextcloud/files'

Check failure on line 182 in src/views/Viewer.vue

View workflow job for this annotation

GitHub Actions / NPM lint

'/home/runner/actions-runner/_work/viewer/viewer/node_modules/@nextcloud/files/dist/index.d.ts' imported multiple times
import { showError } from '@nextcloud/dialogs'
import axios from '@nextcloud/axios'

Expand All @@ -202,13 +202,14 @@ 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'

Check failure on line 205 in src/views/Viewer.vue

View workflow job for this annotation

GitHub Actions / NPM lint

'/home/runner/actions-runner/_work/viewer/viewer/node_modules/@nextcloud/files/dist/index.d.ts' imported multiple times

// Dynamic loading
const NcModal = () => import('@nextcloud/vue/dist/Components/NcModal.js')
const NcActionLink = () => import('@nextcloud/vue/dist/Components/NcActionLink.js')
const NcActionButton = () => import('@nextcloud/vue/dist/Components/NcActionButton.js')

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

components: {
Expand Down Expand Up @@ -931,7 +932,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 @@ -1084,16 +1085,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 @@ -1162,7 +1172,7 @@ export default {
},

},
}
})
</script>

<style lang="scss" scoped>
Expand Down

0 comments on commit 67647c4

Please sign in to comment.