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
+16 -1
View File
@@ -611,6 +611,19 @@ export class AgendaPage implements OnInit {
delete this.loadRequest[index]
}
removeDuplicatesByOwnerUserId = (array) => {
const seen = new Set();
return array.filter(item => {
if (seen.has(item.OwnerUserId)) {
return false;
} else {
seen.add(item.OwnerUserId);
return true;
}
});
};
async loadRangeEventRun(startTime: Date, endTime: Date) {
if (SessionStore.user.OwnerCalendars.length == 0 && SessionStore.user.SharedCalendars.length == 0) {
@@ -632,8 +645,9 @@ export class AgendaPage implements OnInit {
this.myCal.loadEvents();
} catch (error) {}
let load = 0;
for (const selectedCalendar of selectedCalendarIds) {
for (const selectedCalendar of this.removeDuplicatesByOwnerUserId(selectedCalendarIds)) {
const response = await this.AgendaDataRepositoryService.EventList({userId: selectedCalendar.OwnerUserId, calendarOwnerName: selectedCalendar['FullName'] })
@@ -654,6 +668,7 @@ export class AgendaPage implements OnInit {
this.CalendarStore.pushEvent(eventsList, label, selectedCalendar.OwnerUserId);
this.listToPresent = this.CalendarStore.getEventsByCalendarIds(selectedCalendarIds)
// console.log('this.listToPresent', this.listToPresent)
this.showTimelinePR = true;
load++
@@ -186,7 +186,7 @@ export class ViewEventPage implements OnInit {
}
setTimeZone() {
this.TimeZoneString = this.loadedEvent.TimeZone.split(')')[1]
this.TimeZoneString = this.loadedEvent.TimeZone
}
async loadEvent() {