From 17d0afe3b73077b75d22d9b14dfca6a19ab5132e Mon Sep 17 00:00:00 2001 From: Enjeck C Date: Sun, 27 Apr 2025 09:00:49 +0100 Subject: [PATCH 1/2] feat: Setting to show last viewed note or welcome screen on start up Signed-off-by: Enjeck C --- lib/Service/SettingsService.php | 6 ++++++ src/App.vue | 18 ++++++++++++++---- src/components/AppSettings.vue | 18 ++++++++++++++++++ 3 files changed, 38 insertions(+), 4 deletions(-) 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..398cc532f 100644 --- a/src/App.vue +++ b/src/App.vue @@ -139,7 +139,13 @@ export default { } if (data.notes !== null) { this.error = false - this.routeDefault(data.lastViewedNote) + console.log('settings', store.state.app.settings) + 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 +214,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) From 0e6f5243b39adba73c448d5802b1d9106455c126 Mon Sep 17 00:00:00 2001 From: Enjeck C Date: Wed, 25 Jun 2025 19:56:48 +0100 Subject: [PATCH 2/2] fix: lint Signed-off-by: Enjeck C --- src/App.vue | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/App.vue b/src/App.vue index 398cc532f..37573edf3 100644 --- a/src/App.vue +++ b/src/App.vue @@ -134,18 +134,16 @@ export default { fetchNotes() .then(data => { if (data === null) { - // nothing changed return } if (data.notes !== null) { this.error = false - console.log('settings', store.state.app.settings) 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