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; } })); }
public static IDisposable BindNotifications( this MessengerModel model) { return(BindNotifications( model, Locator.Current.GetService <INotificationSource>(), Locator.Current.GetService <INotificationController>())); }
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); } })); }
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; } })); }
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; } })); }
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; } })); }
public static IDisposable BindCatalog(this MessengerModel model, Section section) { model.CatalogModel = new CatalogModel(section); return(Disposable.Empty); }