From 9c9a3fc030d7f06086106b1d9f1d3703c201b6b8 Mon Sep 17 00:00:00 2001 From: zadam Date: Mon, 20 Sep 2021 21:12:35 +0200 Subject: [PATCH] small refactorings of auto readonly size --- src/public/app/dialogs/options/other.js | 26 ++++++++++++------------- src/public/app/services/note_context.js | 8 ++++---- src/routes/api/options.js | 4 ++-- src/services/options_init.js | 4 ++-- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/public/app/dialogs/options/other.js b/src/public/app/dialogs/options/other.js index aa5458f41..99bde91ec 100644 --- a/src/public/app/dialogs/options/other.js +++ b/src/public/app/dialogs/options/other.js @@ -85,16 +85,16 @@ const TPL = `

Automatic readonly size

-

Automatic readonly note size is the size after which notes will be readonly if automatic readonly is enabled.

+

Automatic readonly note size is the size after which notes will be displayed in a readonly mode (for performance reasons).

- - + +
- - + +
`; @@ -184,19 +184,19 @@ export default class ProtectedSessionOptions { return false; }); - this.$autoReadonlySize = $("#automatic-readonly-size-text"); + this.$autoReadonlySizeText = $("#auto-readonly-size-text"); - this.$autoReadonlySize.on('change', () => { - const opts = { 'autoReadonlySize': this.$autoReadonlySize.val() }; + this.$autoReadonlySizeText.on('change', () => { + const opts = { 'autoReadonlySizeText': this.$autoReadonlySizeText.val() }; server.put('options', opts).then(() => toastService.showMessage("Options change have been saved.")); return false; }); - this.$autoCodeReadonlySize = $("#automatic-readonly-size-code"); + this.$autoReadonlySizeCode = $("#auto-readonly-size-code"); - this.$autoCodeReadonlySize.on('change', () => { - const opts = { 'autoCodeReadonlySize': this.$autoReadonlySize.val() }; + this.$autoReadonlySizeCode.on('change', () => { + const opts = { 'autoReadonlySizeCode': this.$autoReadonlySizeText.val() }; server.put('options', opts).then(() => toastService.showMessage("Options change have been saved.")); return false; @@ -214,7 +214,7 @@ export default class ProtectedSessionOptions { this.$imageMaxWidthHeight.val(options['imageMaxWidthHeight']); this.$imageJpegQuality.val(options['imageJpegQuality']); - this.$autoReadonlySize.val(options['autoReadonlySize']); - this.$autoCodeReadonlySize.val(options['autoCodeReadonlySize']); + this.$autoReadonlySizeText.val(options['autoReadonlySizeText']); + this.$autoReadonlySizeCode.val(options['autoReadonlySizeCode']); } } diff --git a/src/public/app/services/note_context.js b/src/public/app/services/note_context.js index c5c0de959..b51db1ce8 100644 --- a/src/public/app/services/note_context.js +++ b/src/public/app/services/note_context.js @@ -193,12 +193,12 @@ class NoteContext extends Component { const noteComplement = await this.getNoteComplement(); - const SIZE_LIMIT = this.note.type === 'text' ? - options.getInt('autoReadonlySize') - : options.getInt('autoCodeReadonlySize'); + const sizeLimit = this.note.type === 'text' ? + options.getInt('autoReadonlySizeText') + : options.getInt('autoReadonlySizeCode'); return noteComplement.content - && noteComplement.content.length > SIZE_LIMIT + && noteComplement.content.length > sizeLimit && !this.note.hasLabel('autoReadOnlyDisabled'); } diff --git a/src/routes/api/options.js b/src/routes/api/options.js index 8f1463267..aa888b9fa 100644 --- a/src/routes/api/options.js +++ b/src/routes/api/options.js @@ -43,8 +43,8 @@ const ALLOWED_OPTIONS = new Set([ 'similarNotesExpanded', 'headingStyle', 'autoCollapseNoteTree', - 'autoReadonlySize', - 'autoCodeReadonlySize' + 'autoReadonlySizeText', + 'autoReadonlySizeCode' ]); function getOptions() { diff --git a/src/services/options_init.js b/src/services/options_init.js index 81913fabe..9b37ac224 100644 --- a/src/services/options_init.js +++ b/src/services/options_init.js @@ -87,8 +87,8 @@ const defaultOptions = [ { name: 'debugModeEnabled', value: 'false', isSynced: false }, { name: 'headingStyle', value: 'underline', isSynced: true }, { name: 'autoCollapseNoteTree', value: 'true', isSynced: true }, - { name: 'autoReadonlySize', value: '10000', isSynced: false }, - { name: 'autoCodeReadonlySize', value: '30000', isSynced: false }, + { name: 'autoReadonlySizeText', value: '10000', isSynced: false }, + { name: 'autoReadonlySizeCode', value: '30000', isSynced: false }, ]; function initStartupOptions() {