Esempio n. 1
0
        public IObservable <Suggestion> GetSuggestions()
        {
            var now          = timeService.CurrentDateTime;
            var startOfRange = now - lookBackTimeSpan;
            var endOfRange   = now + lookAheadTimeSpan;

            var eventsObservable = calendarService
                                   .GetEventsInRange(startOfRange, endOfRange)
                                   .Select(events => events.Where(eventHasDescription))
                                   .SelectMany(orderByOffset);

            var selectedUserCalendars = interactorFactory
                                        .GetUserCalendars()
                                        .Execute()
                                        .Select(calendars => calendars.Where(c => c.IsSelected));

            var eventsFromSelectedUserCalendars = eventsObservable.WithLatestFrom(selectedUserCalendars,
                                                                                  (calendarItem, calendars) =>
                                                                                  (calendarItem: calendarItem, userCalendarIds: calendars.Select(c => c.Id)))
                                                  .Where(tuple => tuple.userCalendarIds.Contains(tuple.calendarItem.CalendarId))
                                                  .Select(tuple => tuple.calendarItem);

            return(interactorFactory.GetDefaultWorkspace().Execute()
                   .CombineLatest(
                       eventsFromSelectedUserCalendars,
                       (workspace, calendarItem) => suggestionFromEvent(calendarItem, workspace.Id))
                   .Take(maxCalendarSuggestionCount)
                   .OnErrorResumeEmpty());
        }
Esempio n. 2
0
        protected async Task ReloadCalendars()
        {
            var calendars = await interactorFactory
                            .GetUserCalendars()
                            .Execute()
                            .Catch((NotAuthorizedException _) => Observable.Return(new List <UserCalendar>()))
                            .Select(group);

            calendarsSubject.OnNext(calendars);
        }
Esempio n. 3
0
        public override async Task Initialize()
        {
            await base.Initialize();

            Calendars = interactorFactory
                        .GetUserCalendars()
                        .Execute()
                        .Catch((NotAuthorizedException _) => Observable.Return(new List <UserCalendar>()))
                        .Select(group);

            SelectedCalendarIds.AddRange(userPreferences.EnabledCalendarIds());
        }