public async Task <IEnumerable <ToastNotification> > CreateNotifications(TodoistService todoist)
        {
            var today = await todoist.GetLabel("today");

            List <Item> allTodos = await todoist.GetItems();

            List <Item> todos = allTodos.Where(i => i.Labels.Contains(today.Id)).OrderBy(i => i.Priority).ToList();
            //if(todos.Count == 0)
            //{
            //    todos = allTodos.Where(i => i.DueDateUtc < DateTime.UtcNow.Date.AddDays(1)).ToList();
            //}
            var proj = await todoist.GetProjects();

            return(todos.Select(i => (todo: i, toast: new ToastContent()
            {
                Visual = GetVisual(i, proj.First(j => j.Id == i.ProjectId)),
                Actions = GetActions(i.Id),

                // Arguments when the user taps body of toast
                Launch = new QueryString()
                {
                    { "action", "viewConversation" },
                    { "conversationId", i.Id.ToString() }
                }.ToString(),
                ActivationType = ToastActivationType.Background,
            })).Select(i => new ToastNotification(i.toast.GetXml())
            {
                SuppressPopup = true,
                Tag = i.todo.Id.ToString()
            }));
        }
Ejemplo n.º 2
0
        private async void Page_Loaded(object sender, RoutedEventArgs e)
        {
            settings = await new UwpMemory().Read("settings.json", new Settings
            {
            });
            Todoist = new TodoistService(settings.TodoistKey, settings.TodoistUserAgent);

            try
            {
                todayLabel = await Todoist.GetLabel("today");
            }
            catch (Exception ex)
            {
                await ContentDialogTodoistKey.ShowAsync();

                Todoist    = new TodoistService(settings.TodoistKey, settings.TodoistUserAgent);
                todayLabel = await Todoist.GetLabel("today");
            }

            Projects = Order(await Todoist.GetProjects()).ToList();
            Labels   = await Todoist.GetLabels();

            Items = await Todoist.GetItems();

            await new NotificationHandler().UpdateNotifications(Todoist);
            await Singleton <LiveTileService> .Instance.SampleUpdate(Todoist);

            OnPropertyChanged(nameof(InstanceLabels));
            OnPropertyChanged(nameof(InstanceProjects));
            OnPropertyChanged(nameof(InstanceItems));

            parser = new TodoistParser(Projects, Labels);

            RedoTodos();

            isLoaded = true;
        }