Skip to content

Commit

Permalink
refactor: simplify code structure in drawio app
Browse files Browse the repository at this point in the history
  • Loading branch information
kulmann committed Oct 10, 2022
1 parent 6b227df commit 36bdb10
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions packages/web-app-draw-io/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@ export default defineComponent({
return `${this.config.url}?${query}`
}
},
watch: {
currentFileContext: {
handler: function () {
this.load()
},
immediate: true
}
},
created() {
this.filePath = this.currentFileContext.path
this.fileExtension = this.filePath.split('.').pop()
Expand Down Expand Up @@ -124,10 +132,9 @@ export default defineComponent({
this.errorPopup(error)
}
},
load() {
this.checkPermissions()
this.getFileContents(this.currentFileContext)
.then((resp) => {
loadFileContent() {
try {
return this.getFileContents(this.currentFileContext).then((resp) => {
this.currentETag = resp.headers.ETag
this.$refs.drawIoEditor.contentWindow.postMessage(
JSON.stringify({
Expand All @@ -138,11 +145,14 @@ export default defineComponent({
'*'
)
})
.catch((error) => {
this.errorPopup(error)
})
} catch (error) {
this.errorPopup(error)
}
},
async importVisio() {
async load() {
await Promise.all([this.checkPermissions(), this.loadFileContent()])
},
importVisio() {
const getDescription = () =>
this.$gettextInterpolate(
this.$gettext('The diagram will open as a new .drawio file: %{file}'),
Expand Down Expand Up @@ -232,14 +242,6 @@ export default defineComponent({
getTimestamp() {
return DateTime.local().toFormat('YYYYMMDD[T]HHmmss')
}
},
watch: {
currentFileContext: {
handler: function () {
this.load()
},
immediate: true
}
}
})
</script>
Expand Down

0 comments on commit 36bdb10

Please sign in to comment.