Show restored events immediately

Signed-off-by: Richard Steinmetz <richard@steinmetz.cloud>
This commit is contained in:
Richard Steinmetz 2021-06-04 20:21:04 +02:00
parent e4b0d21127
commit 900e293f7f
No known key found for this signature in database
GPG Key ID: 31BA3356F0FA2874
2 changed files with 24 additions and 2 deletions

View File

@ -49,6 +49,10 @@ export default function(store) {
logger.error(`EventSource: Timezone ${timeZone} not found, falling back to UTC.`)
}
// This code assumes that once a time range has been fetched it won't be changed
// outside of the vuex store. Triggering a refetch will just update all known
// calendar objects inside this time range. New events that were added to a cached
// time range externally will not be fetched and have to be added manually.
const timeRange = store.getters.getTimeRangeForCalendarCoveringRange(calendar.id, getUnixTimestampFromDate(start), getUnixTimestampFromDate(end))
if (!timeRange) {
let timeRangeId

View File

@ -688,13 +688,31 @@ const actions = {
commit('removeDeletedCalendar', { calendar })
},
async restoreCalendarObject({ commit, state, dispatch }, { vobject }) {
async restoreCalendarObject({ commit, state, getters }, { vobject }) {
await state.trashBin.restore(vobject.uri)
// Clean up the data locally
commit('removeDeletedCalendarObject', { vobject })
// Make sure the affected calendar is refreshed
// Delete cached time range that includes the restored event
const calendarObject = mapCDavObjectToCalendarObject(vobject.dav, undefined)
const component = calendarObject.calendarComponent.getFirstComponent(vobject.objectType)
const timeRange = getters.getTimeRangeForCalendarCoveringRange(
vobject.calendar.id,
component.startDate.unixTime,
component.endDate.unixTime,
)
if (timeRange) {
commit('deleteFetchedTimeRangeFromCalendar', {
calendar: vobject.calendar,
fetchedTimeRangeId: timeRange.id,
})
commit('removeTimeRange', {
timeRangeId: timeRange.id,
})
}
// Trigger calendar refresh
commit('incrementModificationCount')
},