fix duplication events

This commit is contained in:
Peter Maquiran
2024-06-03 13:28:18 +01:00
parent f38b445bd4
commit 320e7c41b3
10 changed files with 99 additions and 32 deletions
+19 -11
View File
@@ -63,9 +63,10 @@ export class CalendarService {
}
removeRangeForCalendar(rangeStartDate, rangeEndDate, profile, calendarId) {
this._eventSource = this._eventSource.filter((e)=> {
if(new Date(rangeStartDate).getTime() <= new Date(e.startTime).getTime() &&
new Date(rangeEndDate).getTime() >= new Date(e.endTime).getTime() && e.CalendarId == calendarId) {
new Date(rangeEndDate).getTime() >= new Date(e.endTime).getTime() && e.CalendarId != calendarId) {
return false
}
return true
@@ -77,16 +78,23 @@ export class CalendarService {
let news = []
eventsList.forEach((element, eventIndex) => {
news.push({
startTime: new Date(element.StartDate),
endTime: new Date(element.EndDate),
allDay: false,
event: element,
calendarName: element.CalendarName,
profile: profile,
id: element.EventId,
CalendarId: CalendarId
});
const found = this._eventSource.find( e => e.id == element.EventId)
if(!found) {
news.push({
startTime: new Date(element.StartDate),
endTime: new Date(element.EndDate),
allDay: false,
event: element,
calendarName: element.CalendarName,
profile: profile,
id: element.EventId,
CalendarId: CalendarId
});
} else {
console.log('found')
}
});