Return writable calendar as default calendar

Signed-off-by: Raimund Schlüßler <raimund.schluessler@mailbox.org>
This commit is contained in:
Raimund Schlüßler 2020-01-29 20:28:00 +01:00
parent d8a26c7fc8
commit c8ad86cd66
No known key found for this signature in database
GPG key ID: 036FA7EB1A599178

View file

@ -233,7 +233,12 @@ const getters = {
* @returns {Calendar} The default calendar
*/
getDefaultCalendar: (state, getters, rootState) => {
return getters.getCalendarById(rootState.settings.settings.defaultCalendarId) || getters.getSortedCalendars[0]
const defaultCalendar = getters.getCalendarById(rootState.settings.settings.defaultCalendarId)
// If the default calendar is read only we return the first calendar that is writable
if (!defaultCalendar || defaultCalendar.readOnly) {
return getters.getSortedCalendars.find(calendar => !calendar.readOnly) || getters.getSortedCalendars[0]
}
return defaultCalendar
}
}