diff --git a/lib/Service/SettingsService.php b/lib/Service/SettingsService.php index 8fc62a687..9af14eb7a 100644 --- a/lib/Service/SettingsService.php +++ b/lib/Service/SettingsService.php @@ -68,6 +68,12 @@ public function __construct( return '.' . $out; }, ], + 'loadRecentOnStartUp' => [ + 'default' => true, + 'validate' => function ($value) { + return $value === 'true' || $value === true; + }, + ], ]; } diff --git a/src/App.vue b/src/App.vue index badd8d24c..37573edf3 100644 --- a/src/App.vue +++ b/src/App.vue @@ -134,12 +134,16 @@ export default { fetchNotes() .then(data => { if (data === null) { - // nothing changed return } if (data.notes !== null) { this.error = false - this.routeDefault(data.lastViewedNote) + if (store.state.app.settings?.loadRecentOnStartUp) { + this.routeDefault(data.lastViewedNote) + } else { + this.routeWelcome() + } + } else if (this.loading.notes) { // only show error state if not loading in background this.error = data.errorMessage @@ -208,9 +212,13 @@ export default { if (availableNotes.length > 0) { this.routeToNote(availableNotes[0].id) } else { - if (this.$route.name !== 'welcome') { - this.$router.push({ name: 'welcome' }) - } + this.routeWelcome() + } + }, + + routeWelcome() { + if (this.$route.name !== 'welcome') { + this.$router.push({ name: 'welcome' }) } }, diff --git a/src/components/AppSettings.vue b/src/components/AppSettings.vue index 4d086dd48..bd27659f7 100644 --- a/src/components/AppSettings.vue +++ b/src/components/AppSettings.vue @@ -34,6 +34,11 @@ @click="onChangeNotePath" > + + + Load recently updated note on startup + +

{{ t('notes', 'File extension for new notes') }} @@ -87,6 +92,7 @@ import { NcAppSettingsDialog, NcAppSettingsSection, + NcCheckboxRadioSwitch, } from '@nextcloud/vue' import { getFilePickerBuilder } from '@nextcloud/dialogs' @@ -101,6 +107,7 @@ export default { components: { NcAppSettingsDialog, NcAppSettingsSection, + NcCheckboxRadioSwitch, HelpMobile, }, @@ -192,6 +199,17 @@ export default { }) }, + onChangeStartUp(event) { + this.saving = true + this.settings.loadRecentOnStartUp = event.target.checked + return setSettings(this.settings) + .catch(() => { + }) + .then(() => { + this.saving = false + }) + }, + setSettingsOpen(newValue) { this.settingsOpen = newValue this.$emit('update:open', newValue)