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

            return(messages // .Merge(chats)
                   .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;
                }
            }));
        }
Exemplo n.º 2
0
 public static IDisposable BindNotifications(
     this MessengerModel model)
 {
     return(BindNotifications(
                model,
                Locator.Current.GetService <INotificationSource>(),
                Locator.Current.GetService <INotificationController>()));
 }
Exemplo 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);
         }
     }));
 }
Exemplo 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;
                }
            }));
        }
Exemplo n.º 5
0
        public static IDisposable BindHome(this MessengerModel model)
        {
            model.HomepageModel = HomepageModel.Hidden();

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

                default:
                    model.HomepageModel = HomepageModel.Hidden();
                    break;
                }
            }));
        }
Exemplo 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;
                }
            }));
        }
Exemplo n.º 7
0
        public static IDisposable BindCatalog(this MessengerModel model, Section section)
        {
            model.CatalogModel = new CatalogModel(section);

            return(Disposable.Empty);
        }