Skip to content

Commit 8ad0519

Browse files
committed
refactor: Remove obsolete hasUnsavedChanges logic
It used to check if the last saved version of the document is older than the current version. But `document.currentVersion` no longer exists in the backend response, so this didn't work since quite some time. Signed-off-by: Jonas <jonas@freesources.org>
1 parent 4198147 commit 8ad0519

3 files changed

Lines changed: 4 additions & 6 deletions

File tree

src/components/Editor.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,7 @@ export default {
642642
this.emit('ready')
643643
}
644644
if (Object.prototype.hasOwnProperty.call(state, 'dirty')) {
645-
// ignore initial loading and other automated changes
645+
// ignore initial loading and other automated changes before first user change
646646
if (this.$editor
647647
&& (this.$editor.can().undo() || this.$editor.can().redo())
648648
) {

src/components/Editor/Status.vue

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,22 +86,19 @@ export default {
8686
return this.dirtyStateIndicator ? t('text', 'Saving …') : t('text', 'Saved')
8787
},
8888
dirtyStateIndicator() {
89-
return this.dirty || this.hasUnsavedChanges
89+
return this.dirty
9090
},
9191
lastSavedStatusTooltip() {
9292
let message = t('text', 'Last saved {lastSave}', { lastSave: this.lastSavedString })
9393
if (this.hasSyncCollission) {
9494
message = t('text', 'The document has been changed outside of the editor. The changes cannot be applied.')
9595
}
96-
if (this.dirty || this.hasUnsavedChanges) {
96+
if (this.dirty) {
9797
message += ' - ' + t('text', 'Unsaved changes')
9898
}
9999
return message
100100
},
101101
102-
hasUnsavedChanges() {
103-
return this.document && this.document.lastSavedVersion < this.document.currentVersion
104-
},
105102
hasSyncCollission() {
106103
return this.syncError && this.syncError.type === ERROR_TYPE.SAVE_COLLISSION
107104
},

src/services/SyncService.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ class SyncService {
218218
this.emit('error', { type: ERROR_TYPE.PUSH_FORBIDDEN, data: {} })
219219
}
220220
// TODO: does response.data ever have a document? maybe for errors?
221+
// TODO: `currentVersion` is always 0 nowadays. Check if this is still needed.
221222
// Only emit conflict event if we have synced until the latest version
222223
if (response.data.document?.currentVersion === this.version) {
223224
this.emit('error', { type: ERROR_TYPE.PUSH_FAILURE, data: {} })

0 commit comments

Comments
 (0)