Inheritance: IMessageConsumer, IUnreadCounter
Ejemplo n.º 1
0
 private void HandleCounter(AggregatedMessageCounter sender)
 {
     if (_counter.HasMessages)
     {
         var indicator = GetOrCreateIndicator();
         if (indicator == null) return;
         indicator.Visibility = Visibility.Visible;
     }
     else
     {
         if (_indicator == null) return;
         _indicator.Visibility = Visibility.Collapsed;
     }
 }
Ejemplo n.º 2
0
 public void StartListen()
 {
     _aggregatedCounter = CreateAggregatedCounter();
     _interlocutorUnit = ModelContext
             .Interlocutors
             .HandleCollectionChanges(initialOrAdd: interlocutor =>
             {
                 if (_counters.ContainsKey(interlocutor))
                 {
                     return;
                 }
                 var counter = new UnreadMessageCounter(interlocutor, this);
                 _counters.Add(interlocutor, counter);
                 Feed.Subscribe(counter);
             }, removed: interlocutor =>
             {
                 if (!_counters.ContainsKey(interlocutor)) return;
                 var counter = _counters[interlocutor];
                 foreach (var msg in counter.TrackingMessages.ToList())
                 {
                     MarkAsRead(msg);
                 }
                 Feed.Unsubscribe(counter);
                 _counters.Remove(interlocutor);
             });
 }
Ejemplo n.º 3
0
 public void Initialize()
 {
     _counter = StateManager.AggregatedCounter;
     _counterUnit = _counter.SubscribeToChange(() => _counter.HasMessages, HandleCounter);
 }
Ejemplo n.º 4
0
 private AggregatedMessageCounter CreateAggregatedCounter()
 {
     var counter = new AggregatedMessageCounter();
     Feed.Subscribe(counter);
     return counter;
 }