Skip to content

Commit

Permalink
Merge pull request #3277 from nextcloud/bugfix/main/saveas-update
Browse files Browse the repository at this point in the history
  • Loading branch information
juliusknorr authored Nov 7, 2023
2 parents 78bc8cd + 3f6bbc3 commit a85616c
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions src/view/FilesAppIntegration.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export default {
})
}

this.getFileNode()
this.getFileNode(true)
},

registerHandler(event, callback) {
Expand Down Expand Up @@ -102,7 +102,7 @@ export default {
$('#richdocuments-header').remove()
},

saveAs(newName) {
async saveAs(newName) {
const oldFile = this.getFileModel()

if (this.handlers.saveAs && this.handlers.saveAs(this)) {
Expand All @@ -113,8 +113,19 @@ export default {
this.fileName = newName
}

const node = await this.getFileNode(true)

if (!node) {
return
}

this.changeFilesRoute(node.fileid)

OCA?.Files?.Sidebar?.close()

if (this.getFileList()) {
const newFileModel = oldFile.clone()
newFileModel.set('id', node.fileid)
newFileModel.set('name', newName)
newFileModel.set('mtime', Date.now())
this.getFileList()
Expand Down Expand Up @@ -518,8 +529,8 @@ export default {
fileInfo.trigger('change', this.getFileModel())
},

async getFileNode() {
if (this.fileNode !== undefined) {
async getFileNode(forceFetch = false) {
if (this.fileNode !== undefined && !forceFetch) {
return this.fileNode
}

Expand All @@ -541,4 +552,13 @@ export default {
return this.fileNode
},

changeFilesRoute(fileId) {
OCP?.Files?.Router?.goToRoute(
OCP.Files.Router.name,
{ ...OCP.Files.Router.params, fileid: fileId },
OCP.Files.Router.query,
true
)
},

}

0 comments on commit a85616c

Please sign in to comment.