Skip to content

Commit

Permalink
Improve handling of Node API properties
Browse files Browse the repository at this point in the history
Signed-off-by: Louis Chemineau <[email protected]>
  • Loading branch information
artonge committed Jan 17, 2024
1 parent 6c29e7e commit 3d15cb4
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/views/Viewer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ import Vue from 'vue'
import axios from '@nextcloud/axios'
import { showError } from '@nextcloud/dialogs'
import { emit, subscribe, unsubscribe } from '@nextcloud/event-bus'
import { registerFileAction, FileAction, Permission, DefaultType } from '@nextcloud/files'
import { registerFileAction, FileAction, Permission, DefaultType, Node } from '@nextcloud/files'
import getSortingConfig from '../services/FileSortingConfig.ts'

import isFullscreen from '@nextcloud/vue/dist/Mixins/isFullscreen.js'
Expand Down Expand Up @@ -1113,12 +1113,19 @@ export default {
},

// Update etag of updated file to break cache.
/**
*
* @param {Node} node
*/
async handleFileUpdated(node) {
const index = this.fileList.findIndex(({ fileid: currentFileId }) => currentFileId === node.fileid)

this.fileList.splice(index, 1, { ...node, etag: node.etag })
// Ensure compatibility with the legacy data model that the Viewer is using. (see "model.ts").
// This can be removed once Viewer is migrated to the new Node API.
node.etag = node.attributes.etag
this.fileList.splice(index, 1, node)
if (node.fileid === this.currentFile.fileid) {
this.currentFile.etag = node.etag
this.currentFile.etag = node.attributes.etag
}
},

Expand Down

0 comments on commit 3d15cb4

Please sign in to comment.