hopefully won't double-enqueue if it happens to check calendars again while the previous event is waiting

This commit is contained in:
Adam R. Grey 2021-09-03 11:44:44 -04:00
parent d2f384f4d7
commit 1fe14e966f
2 changed files with 9 additions and 4 deletions

View File

@ -131,8 +131,13 @@ namespace director
Occurrence = occurrence, Occurrence = occurrence,
Showtime = occurrence.OccurrenceStart Showtime = occurrence.OccurrenceStart
}; };
createSchedulable(ref newSchedulable); var asActualEvent = iCalHoopJumping.parseEvent(calLabel, occurrence.Event);
scratch.agenda.Add(newSchedulable);
if(scratch.agenda.FirstOrDefault(s => iCalHoopJumping.parseEvent(calLabel, s.Occurrence.Event)?.Uid == asActualEvent.Uid) == null)
{
createSchedulable(ref newSchedulable);
scratch.agenda.Add(newSchedulable);
}
} }
} }
} }

View File

@ -20,12 +20,12 @@ namespace director
//I don't understand why the entire .net ecosystem insists on ignoring ToString(). Is it really that much fun writing ThingSerializerFactory? ...java programmers. //I don't understand why the entire .net ecosystem insists on ignoring ToString(). Is it really that much fun writing ThingSerializerFactory? ...java programmers.
private static EventSerializer ser = new EventSerializer(); private static EventSerializer ser = new EventSerializer();
public static CalendarEvent parseEvent(string calendar, string eventStr) public static CalendarEvent parseEvent(string calendarLabel, string eventStr)
{ {
//return new CalendarEvent(eventStr); //lol no //return new CalendarEvent(eventStr); //lol no
//return CalendarEvent.Parse(eventStr); //lol no //return CalendarEvent.Parse(eventStr); //lol no
var cal = Calendar.Load(Program.scratch.Calendars[calendar]); var cal = Calendar.Load(Program.scratch.Calendars[calendarLabel]);
foreach (var evt in cal.Events) foreach (var evt in cal.Events)
{ {
if (ser.SerializeToString(evt) == eventStr) if (ser.SerializeToString(evt) == eventStr)