Skip to content

Commit a7cf79a

Browse files
committed
feat: Setting to show last viewed note or welcome screen on start up
Signed-off-by: Enjeck C <[email protected]>
1 parent 5013f5f commit a7cf79a

File tree

3 files changed

+38
-4
lines changed

3 files changed

+38
-4
lines changed

lib/Service/SettingsService.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,12 @@ public function __construct(
6868
return '.' . $out;
6969
},
7070
],
71+
'loadRecentOnStartUp' => [
72+
'default' => true,
73+
'validate' => function ($value) {
74+
return $value === 'true' || $value === true;
75+
},
76+
],
7177
];
7278
}
7379

src/App.vue

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,13 @@ export default {
139139
}
140140
if (data.notes !== null) {
141141
this.error = false
142-
this.routeDefault(data.lastViewedNote)
142+
console.log('settings', store.state.app.settings)
143+
if (store.state.app.settings?.loadRecentOnStartUp) {
144+
this.routeDefault(data.lastViewedNote)
145+
} else {
146+
this.routeWelcome()
147+
}
148+
143149
} else if (this.loading.notes) {
144150
// only show error state if not loading in background
145151
this.error = data.errorMessage
@@ -208,9 +214,13 @@ export default {
208214
if (availableNotes.length > 0) {
209215
this.routeToNote(availableNotes[0].id)
210216
} else {
211-
if (this.$route.name !== 'welcome') {
212-
this.$router.push({ name: 'welcome' })
213-
}
217+
this.routeWelcome()
218+
}
219+
},
220+
221+
routeWelcome() {
222+
if (this.$route.name !== 'welcome') {
223+
this.$router.push({ name: 'welcome' })
214224
}
215225
},
216226

src/components/AppSettings.vue

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@
3434
@click="onChangeNotePath"
3535
>
3636
</NcAppSettingsSection>
37+
<NcAppSettingsSection id="start-up-section" :name="t('notes', 'Start Up')">
38+
<NcCheckboxRadioSwitch :checked.sync="settings.loadRecentOnStartUp" @update:checked="onChangeSettings">
39+
Load recently updated note on startup
40+
</NcCheckboxRadioSwitch>
41+
</NcAppSettingsSection>
3742
<NcAppSettingsSection id="file-suffix-section" :name="t('notes', 'File extension')">
3843
<p class="app-settings-section__desc">
3944
{{ t('notes', 'File extension for new notes') }}
@@ -87,6 +92,7 @@
8792
import {
8893
NcAppSettingsDialog,
8994
NcAppSettingsSection,
95+
NcCheckboxRadioSwitch,
9096
} from '@nextcloud/vue'
9197
9298
import { getFilePickerBuilder } from '@nextcloud/dialogs'
@@ -101,6 +107,7 @@ export default {
101107
components: {
102108
NcAppSettingsDialog,
103109
NcAppSettingsSection,
110+
NcCheckboxRadioSwitch,
104111
HelpMobile,
105112
},
106113
@@ -192,6 +199,17 @@ export default {
192199
})
193200
},
194201
202+
onChangeStartUp(event) {
203+
this.saving = true
204+
this.settings.loadRecentOnStartUp = event.target.checked
205+
return setSettings(this.settings)
206+
.catch(() => {
207+
})
208+
.then(() => {
209+
this.saving = false
210+
})
211+
},
212+
195213
setSettingsOpen(newValue) {
196214
this.settingsOpen = newValue
197215
this.$emit('update:open', newValue)

0 commit comments

Comments
 (0)