From 8b83768d6b53ffc769936e8753183a9db2fa199e Mon Sep 17 00:00:00 2001 From: Richard Steinmetz Date: Tue, 27 Feb 2024 11:28:29 +0100 Subject: [PATCH] fixup! feat: add a setting for the default calendar url --- src/mixins/EditorMixin.js | 3 +- src/store/calendarObjectInstance.js | 5 ++- src/store/settings.js | 35 +------------------ src/views/Calendar.vue | 1 - .../javascript/unit/models/principal.test.js | 2 ++ tests/javascript/unit/store/settings.test.js | 7 ---- 6 files changed, 6 insertions(+), 47 deletions(-) diff --git a/src/mixins/EditorMixin.js b/src/mixins/EditorMixin.js index a5286f5df7..0b1b5e707d 100644 --- a/src/mixins/EditorMixin.js +++ b/src/mixins/EditorMixin.js @@ -691,11 +691,10 @@ export default { const start = parseInt(to.params.dtstart, 10) const end = parseInt(to.params.dtend, 10) const timezoneId = vm.$store.getters.getResolvedTimezone - const calendarId = vm.$store.state.settings.defaultCalendarId try { await vm.loadingCalendars() - await vm.$store.dispatch('getCalendarObjectInstanceForNewEvent', { isAllDay, start, end, timezoneId, calendarId }) + await vm.$store.dispatch('getCalendarObjectInstanceForNewEvent', { isAllDay, start, end, timezoneId }) vm.calendarId = vm.calendarObject.calendarId } catch (error) { console.debug(error) diff --git a/src/store/calendarObjectInstance.js b/src/store/calendarObjectInstance.js index d3e5ffc5f2..043100321f 100644 --- a/src/store/calendarObjectInstance.js +++ b/src/store/calendarObjectInstance.js @@ -1563,7 +1563,7 @@ const actions = { * @param {string} data.timezoneId The timezoneId of the new event * @return {Promise<{calendarObject: object, calendarObjectInstance: object}>} */ - async getCalendarObjectInstanceForNewEvent({ state, dispatch, commit }, { isAllDay, start, end, timezoneId, calendarId }) { + async getCalendarObjectInstanceForNewEvent({ state, dispatch, commit }, { isAllDay, start, end, timezoneId }) { if (state.isNew === true) { return Promise.resolve({ calendarObject: state.calendarObject, @@ -1571,7 +1571,7 @@ const actions = { }) } - const calendarObject = await dispatch('createNewEvent', { start, end, isAllDay, timezoneId, calendarId }) + const calendarObject = await dispatch('createNewEvent', { start, end, isAllDay, timezoneId }) const startDate = new Date(start * 1000) const eventComponent = getObjectAtRecurrenceId(calendarObject, startDate) const calendarObjectInstance = mapEventComponentToEventObject(eventComponent) @@ -1708,7 +1708,6 @@ const actions = { end: endDate.unixTime, timezoneId: oldEventComponent.startDate.timezoneId, isAllDay: oldEventComponent.isAllDay(), - calendarId: oldEventComponent.calendarId, }) const eventComponent = getObjectAtRecurrenceId(calendarObject, startDate.jsDate) copyCalendarObjectInstanceIntoEventComponent(oldCalendarObjectInstance, eventComponent) diff --git a/src/store/settings.js b/src/store/settings.js index 594ccfd458..21181166d5 100644 --- a/src/store/settings.js +++ b/src/store/settings.js @@ -21,8 +21,7 @@ * along with this program. If not, see . * */ - -import { enableBirthdayCalendar, getCurrentUserPrincipal } from '../services/caldavService.js' +import { enableBirthdayCalendar } from '../services/caldavService.js' import { mapDavCollectionToCalendar } from '../models/calendar.js' import { detectTimezone } from '../services/timezoneDetectionService.js' import { setConfig as setCalendarJsConfig } from '@nextcloud/calendar-js' @@ -56,7 +55,6 @@ const state = { momentLocale: 'en', attachmentsFolder: '/Calendar', attachmentsFolderCreated: false, - defaultCalendarUrl: null, } const mutations = { @@ -162,17 +160,6 @@ const mutations = { state.attachmentsFolderCreated = attachmentsFolderCreated }, - /** - * Updates the user's default calendar - * - * @param {Object} state The Vuex state - * @param {Object} data The destructuring object - * @param {String} data.calendarId The new calendar id - */ - setDefaultCalendarUrl(state, { calendarUrl }) { - state.defaultCalendarUrl = calendarUrl - }, - /** * Initialize settings * @@ -444,26 +431,6 @@ const actions = { commit('setDefaultReminder', { defaultReminder }) }, - /** - * Updates the user's default calendar for new events and invitations - * - * @param {object} vuex The Vuex destructuring object - * @param {object} vuex.state The Vuex state - * @param {Function} vuex.commit The Vuex commit Function - * @param {object} data The destructuring object - * @param {string} data.calendarUrl The url of the new default calendar - */ - async setDefaultCalendarUrl({ commit, state }, { calendarUrl }) { - if (state.defaultCalendarUrl === calendarUrl) { - return - } - - const principal = getCurrentUserPrincipal() - principal.scheduleDefaultCalendarUrl = calendarUrl - await principal.update() - commit('setDefaultCalendarUrl', { calendarUrl }) - }, - /** * Updates the user's timezone * diff --git a/src/views/Calendar.vue b/src/views/Calendar.vue index f72cdcd1f8..6b11170dd5 100644 --- a/src/views/Calendar.vue +++ b/src/views/Calendar.vue @@ -145,7 +145,6 @@ export default { showWeekNumbers: state => state.settings.showWeekNumbers, slotDuration: state => state.settings.slotDuration, defaultReminder: state => state.settings.defaultReminder, - defaultCalendarId: state => state.settings.defaultCalendarId, showTasks: state => state.settings.showTasks, timezone: state => state.settings.timezone, modificationCount: state => state.calendarObjects.modificationCount, diff --git a/tests/javascript/unit/models/principal.test.js b/tests/javascript/unit/models/principal.test.js index 3547014dc7..d3f2317179 100644 --- a/tests/javascript/unit/models/principal.test.js +++ b/tests/javascript/unit/models/principal.test.js @@ -40,6 +40,7 @@ describe('Test suite: Principal model (models/principal.js)', () => { isCalendarResource: false, isCalendarRoom: false, principalId: null, + scheduleDefaultCalendarUrl: null, }) }) @@ -63,6 +64,7 @@ describe('Test suite: Principal model (models/principal.js)', () => { isCalendarRoom: false, principalId: 'bar', otherProp: 'foo', + scheduleDefaultCalendarUrl: null, }) }) diff --git a/tests/javascript/unit/store/settings.test.js b/tests/javascript/unit/store/settings.test.js index cae9eb87e9..961c9cab79 100644 --- a/tests/javascript/unit/store/settings.test.js +++ b/tests/javascript/unit/store/settings.test.js @@ -49,7 +49,6 @@ describe('store/settings test suite', () => { it('should provide a default state', () => { expect(settingsStore.state).toEqual({ appVersion: null, - defaultCalendarId: null, firstRun: null, forceEventAlarmType: false, hideEventExport: false, @@ -163,7 +162,6 @@ describe('store/settings test suite', () => { it('should provide a mutation to set the settings initially', () => { const state = { appVersion: null, - defaultCalendarId: null, firstRun: null, talkEnabled: false, eventLimit: null, @@ -188,7 +186,6 @@ describe('store/settings test suite', () => { const settings = { appVersion: '2.1.0', - defaultCalendarId: 'Personal', eventLimit: false, firstRun: true, showWeekNumbers: true, @@ -216,7 +213,6 @@ describe('store/settings test suite', () => { expect(logInfo).toHaveBeenNthCalledWith(1, ` Initial settings: - AppVersion: 2.1.0 - - DefaultCalendarId: Personal - EventLimit: false - FirstRun: true - ShowWeekNumbers: true @@ -238,7 +234,6 @@ Initial settings: `) expect(state).toEqual({ appVersion: '2.1.0', - defaultCalendarId: 'Personal', eventLimit: false, firstRun: true, showWeekNumbers: true, @@ -265,7 +260,6 @@ Initial settings: it('should provide a mutation to set the resolved moment locale', () => { const state = { appVersion: null, - defaultCalendarId: null, firstRun: null, talkEnabled: false, eventLimit: null, @@ -286,7 +280,6 @@ Initial settings: expect(state).toEqual({ appVersion: null, - defaultCalendarId: null, firstRun: null, talkEnabled: false, eventLimit: null,