Skip to content

Commit

Permalink
if try to add duplicate event, skip instead of throw
Browse files Browse the repository at this point in the history
  • Loading branch information
adzcai committed Jan 14, 2024
1 parent b5a7986 commit c139faf
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/core/EventCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -567,14 +567,16 @@ export default class EventCache {
location,
calendarId: calendar.id,
}));
newEvents.forEach(({ event, id, location }) => {
this.store.add({
calendar,
location,
id,
event,
newEvents
.filter(({ id }) => !this.store.has(id))
.forEach(({ event, id, location }) => {
this.store.add({
calendar,
location,
id,
event,
});
});
});
this.updateCalendar({
id: calendar.id,
editable: false,
Expand Down
4 changes: 4 additions & 0 deletions src/core/EventStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,10 @@ export default class EventStore {
return result;
}

has(id: string): boolean {
return this.store.has(id);
}

/**
* Add a new event to the store with given associations.
* @param param0
Expand Down

0 comments on commit c139faf

Please sign in to comment.