Skip to content

Commit

Permalink
refactor(SyncService): Move hasUnsavedChanges getter to SyncService
Browse files Browse the repository at this point in the history
Signed-off-by: Jonas <jonas@freesources.org>
  • Loading branch information
mejo- authored and max-nextcloud committed Feb 3, 2025
1 parent ff96e6e commit 4e355b5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
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 || this.document.hasUnsavedChanges
},
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 || this.document.hasUnsavedChanges) {
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
4 changes: 4 additions & 0 deletions src/services/SessionApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ export class Connection {
return this.closed
}

get hasUnsavedChanges() {
return this.#document && this.#document.lastSavedVersion < this.#document.currentVersion
}

get #defaultParams() {
return {
documentId: this.#document.id,
Expand Down

0 comments on commit 4e355b5

Please sign in to comment.