Skip to content

Commit a7dc618

Browse files
committed
create central config for interval definitions
1 parent 3f34502 commit a7dc618

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

src/components/Note.vue

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ import {
6363
import { showError } from '@nextcloud/dialogs'
6464
import { emit } from '@nextcloud/event-bus'
6565
66+
import { config } from '../config'
6667
import { fetchNote, refreshNote, saveNote, saveNoteManually, autotitleNote, routeIsNewNote } from '../NotesService'
6768
import TheEditor from './EditorEasyMDE'
6869
import ThePreview from './EditorMarkdownIt'
@@ -244,7 +245,7 @@ export default {
244245
this.refreshTimer = setTimeout(() => {
245246
this.refreshTimer = null
246247
this.refreshNote()
247-
}, 10000)
248+
}, config.interval.note.refresh * 1000)
248249
},
249250
250251
refreshNote() {
@@ -273,7 +274,7 @@ export default {
273274
this.autosaveTimer = setTimeout(() => {
274275
this.autosaveTimer = null
275276
saveNote(note.id)
276-
}, 2000)
277+
}, config.interval.note.autosave * 1000)
277278
}
278279
279280
// (re-) start auto refresh timer
@@ -282,21 +283,17 @@ export default {
282283
283284
// stop old autotitle timer
284285
if (this.autotitleTimer !== null) {
285-
console.debug('clear autotitle timer')
286286
clearTimeout(this.autotitleTimer)
287287
this.autotitleTimer = null
288288
}
289289
// start autotitle timer if note is new
290290
if (this.isNewNote) {
291-
console.debug('start autotitle timer')
292291
this.autotitleTimer = setTimeout(() => {
293-
console.debug('execute autotitle timer')
294292
this.autotitleTimer = null
295293
if (this.isNewNote) {
296-
console.debug('autotitle note')
297294
autotitleNote(note.id)
298295
}
299-
}, 5000)
296+
}, config.interval.note.autotitle * 1000)
300297
}
301298
}
302299
},

src/config.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
export const config = {
2+
interval: {
3+
note: {
4+
autosave: 1,
5+
autotitle: 2,
6+
refresh: 10,
7+
},
8+
},
9+
}

0 commit comments

Comments
 (0)