コード例 #1
0
        public NotificationsListViewModel(INotificationsClient notificationsApi)
        {
            Notifications = new ReactiveList<NotificationTileViewModel>();
            LoadNotifications = new ReactiveCommand();

            var loadedNotifications = LoadNotifications.RegisterAsync(_ =>
                //BlobCache.LocalMachine.GetAndFetchLatest("notifications", () => Observable.Return(new List<Notification>())));
                BlobCache.LocalMachine.GetAndFetchLatest("notifications", () =>
                    notificationsApi.GetAllForCurrent()));

            loadedNotifications.Subscribe(newItems => {
                using (Notifications.SuppressChangeNotifications()) {
                    var toAdd = newItems
                        .Where(x => x.Repository.Owner.Id != 9919 && x.Repository.Owner.Id != 1089146)
                        .Select(x => new NotificationTileViewModel(x))
                        .ToArray();

                    Notifications.Clear();
                    Notifications.AddRange(toAdd);
                    //Notifications.AddRange(new[] { new NotificationTileViewModel(null) });
                }
            });
        }