Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
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 <[email protected]>
  • Loading branch information
mejo- committed Apr 2, 2025
commit 6df5dd16e71be9311f74203ec56b91f6800d4d45
2 changes: 1 addition & 1 deletion src/components/Editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@ export default {
this.emit('ready')
}
if (Object.prototype.hasOwnProperty.call(state, 'dirty')) {
// ignore initial loading and other automated changes
// ignore initial loading and other automated changes before first user change
if (this.$editor
&& (this.$editor.can().undo() || this.$editor.can().redo())
) {
Expand Down
7 changes: 2 additions & 5 deletions src/components/Editor/Status.vue
Original file line number Diff line number Diff line change
Expand Up @@ -89,22 +89,19 @@ export default {
return this.dirtyStateIndicator ? t('text', 'Saving …') : t('text', 'Saved')
},
dirtyStateIndicator() {
return this.dirty || this.hasUnsavedChanges
return this.dirty
},
lastSavedStatusTooltip() {
let message = t('text', 'Last saved {lastSave}', { lastSave: this.lastSavedString })
if (this.hasSyncCollission) {
message = t('text', 'The document has been changed outside of the editor. The changes cannot be applied.')
}
if (this.dirty || this.hasUnsavedChanges) {
if (this.dirty) {
message += ' - ' + t('text', 'Unsaved changes')
}
return message
},

hasUnsavedChanges() {
return this.document && this.document.lastSavedVersion < this.document.currentVersion
},
hasSyncCollission() {
return this.syncError && this.syncError.type === ERROR_TYPE.SAVE_COLLISSION
},
Expand Down
1 change: 1 addition & 0 deletions src/services/SyncService.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ class SyncService {
this.emit('error', { type: ERROR_TYPE.PUSH_FORBIDDEN, data: {} })
}
// TODO: does response.data ever have a document? maybe for errors?
// TODO: `currentVersion` is always 0 nowadays. Check if this is still needed.
// Only emit conflict event if we have synced until the latest version
if (response.data.document?.currentVersion === this.version) {
this.emit('error', { type: ERROR_TYPE.PUSH_FAILURE, data: {} })
Expand Down