Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions js/editor.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/editor.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/files-modal.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion js/files-modal.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions js/text-editors.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/text-editors.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/text-files.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/text-files.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/text-public.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/text-public.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/text-text.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/text-text.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/text-viewer.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/text-viewer.js.map

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion src/components/Editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -326,13 +326,17 @@ export default {
this.$syncService = null
this.$attachmentResolver = null
},
beforeDestroy() {
async beforeDestroy() {
if (!this.richWorkspace) {
window.removeEventListener('beforeprint', this.preparePrinting)
window.removeEventListener('afterprint', this.preparePrinting)
}
unsubscribe('text:image-node:add', this.onAddImageNode)
unsubscribe('text:image-node:delete', this.onDeleteImageNode)
if (this.dirty) {
const timeout = new Promise((resolve) => setTimeout(resolve, 2000))
await Promise.any([timeout, this.$syncService.save()])
Copy link
Member

@juliusknorr juliusknorr Jul 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe I'm missing something but wouldn't this be called after the text session has been closed already then?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. The text session is closed afterwards where we destroy all the providers - one of which is the SyncServiceProvider which will close the session on destruction.
Only if the save takes longer than the timeout the provider will be destroyed never the less.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, makes sense. I just got confused by the close/_close methods of the sync service and how they would be triggered as I assumed that the viewer close calls them, but that doesn't seem to be the case. 👍

}
this.$providers.forEach(p => p.destroy())
},
methods: {
Expand Down
2 changes: 0 additions & 2 deletions src/services/SyncService.js
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,6 @@ class SyncService {

async close() {
this.backend?.disconnect()
const timeout = new Promise((resolve) => setTimeout(resolve, 2000))
await Promise.any([timeout, this.save()])
return this._close()
}

Expand Down