Merge pull request #841 from nextcloud/fix/823

Prevent read-only calendar as default calendar
This commit is contained in:
Raimund Schlüßler 2020-01-29 20:47:23 +01:00 committed by GitHub
commit fb153a0db4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View file

@ -111,7 +111,7 @@ export default {
collections: state => state.collections.collections
}),
...mapGetters({
calendars: 'getSortedCalendars'
calendars: 'getSortedWritableCalendars'
})
},
methods:

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
}
}