Ejemplo n.º 1
0
        public static IDisposable BindNotifications(
            this MessengerModel model,
            INotificationSource notificationSource,
            INotificationController notificationController)
        {
            var chats    = notificationSource.ChatNotifications();
            var messages = notificationSource.MessagesNotifications();

            return(chats.Merge(messages)
                   .Buffer(TimeSpan.FromSeconds(2))
                   .SubscribeOn(RxApp.TaskpoolScheduler)
                   .ObserveOn(RxApp.MainThreadScheduler)
                   .Accept(notifications =>
            {
                switch (notifications.Count)
                {
                case 0:
                    break;

                case 1:
                    notificationController.Show(
                        NotificationModel.FromNotification(notifications[0]));
                    break;

                default:
                    notificationController.Show(
                        NotificationModel.FromNotificationList(notifications));
                    break;
                }
            }));
        }
Ejemplo n.º 2
0
 public static IDisposable BindNotifications(
     this MessengerModel model)
 {
     return(BindNotifications(
                model,
                Locator.Current.GetService <INotificationSource>(),
                Locator.Current.GetService <INotificationController>()));
 }
Ejemplo n.º 3
0
 private static IDisposable SubscribeToSelection(this MessengerModel model, Action <EntryModel> action)
 {
     return(model.WhenAnyValue(ctx => ctx.CatalogModel.SelectedEntry)
            .SubscribeOn(RxApp.TaskpoolScheduler)
            .ObserveOn(RxApp.MainThreadScheduler)
            .Accept(entry =>
     {
         if (entry != null)
         {
             action(entry);
         }
     }));
 }
Ejemplo n.º 4
0
        public static IDisposable BindEditor(this MessengerModel model)
        {
            model.EditorModel = EditorModel.Hidden();

            return(model.SubscribeToSelection(entry =>
            {
                switch (entry)
                {
                case ChatEntryModel chatEntryModel:
                    model.EditorModel = new EditorModel(chatEntryModel.Chat);
                    break;

                default:
                    model.EditorModel = EditorModel.Hidden();
                    break;
                }
            }));
        }
Ejemplo n.º 5
0
        public static IDisposable BindHome(this MessengerModel model)
        {
            model.HomeModel = HomeModel.Hidden();

            return(model.SubscribeToSelection(entry =>
            {
                switch (entry)
                {
                case HomeEntryModel _:
                    model.HomeModel = new HomeModel();
                    break;

                default:
                    model.HomeModel = HomeModel.Hidden();
                    break;
                }
            }));
        }
Ejemplo n.º 6
0
        public static IDisposable BindExplorer(this MessengerModel model)
        {
            model.ExplorerModel = ExplorerModel.Hidden();

            return(model.SubscribeToSelection(entry =>
            {
                switch (entry)
                {
                case ChatEntryModel chatEntryModel:
                    model.ExplorerModel = new ExplorerModel(chatEntryModel.Chat);
                    break;

                case AggregateEntryModel aggregateEntryModel:
                    //model.ExplorerModel = new ExplorerModel(aggregateEntryModel.Aggregate);
                    break;

                case HomeEntryModel _:
                    model.ExplorerModel = ExplorerModel.Hidden();
                    break;
                }
            }));
        }
Ejemplo n.º 7
0
        public static IDisposable BindCatalog(this MessengerModel model, Section section)
        {
            model.CatalogModel = new CatalogModel(section);

            return(Disposable.Empty);
        }