@@ -18,6 +18,7 @@ public class NotificationsViewModel : LoadableViewModel
1818 private readonly FilterableCollectionViewModel < NotificationModel , NotificationsFilterModel > _notifications ;
1919 private ICommand _readAllCommand ;
2020 private ICommand _readCommand ;
21+ private ICommand _readReposCommand ;
2122 private int _shownIndex ;
2223 private bool _isMarking ;
2324
@@ -48,12 +49,17 @@ public bool IsMarking
4849
4950 public ICommand ReadCommand
5051 {
51- get { return _readCommand ?? ( _readCommand = new MvxCommand < NotificationModel > ( x => Read ( x ) ) ) ; }
52+ get { return _readCommand ?? ( _readCommand = new MvxCommand < NotificationModel > ( Read ) ) ; }
5253 }
5354
55+ public ICommand ReadRepositoriesCommand
56+ {
57+ get { return _readReposCommand ?? ( _readReposCommand = new MvxCommand < string > ( MarkRepoAsRead ) ) ; }
58+ }
59+
5460 public ICommand ReadAllCommand
5561 {
56- get { return _readAllCommand ?? ( _readAllCommand = new MvxCommand ( ( ) => MarkAllAsRead ( ) , ( ) => ShownIndex != 2 && ! IsLoading && ! IsMarking ) ) ; }
62+ get { return _readAllCommand ?? ( _readAllCommand = new MvxCommand ( MarkAllAsRead , ( ) => ShownIndex != 2 && ! IsLoading && ! IsMarking && Notifications . Any ( ) ) ) ; }
5763 }
5864
5965 public ICommand GoToNotificationCommand
@@ -132,6 +138,36 @@ private async void Read(NotificationModel model)
132138 }
133139 }
134140
141+ private async void MarkRepoAsRead ( string repo )
142+ {
143+ var items = Notifications . Items . Where ( x => string . Equals ( x . Repository . FullName , repo , StringComparison . OrdinalIgnoreCase ) ) . ToList ( ) ;
144+
145+ try
146+ {
147+ IsMarking = true ;
148+
149+ foreach ( var notification in items )
150+ {
151+ try
152+ {
153+ await this . GetApplication ( ) . Client . ExecuteAsync ( this . GetApplication ( ) . Client . Notifications [ notification . Id ] . MarkAsRead ( ) ) ;
154+ notification . Unread = false ;
155+ }
156+ catch
157+ {
158+ //Ignore?
159+ }
160+ }
161+
162+ Notifications . Items . RemoveRange ( items ) ;
163+ UpdateAccountNotificationsCount ( ) ;
164+ }
165+ finally
166+ {
167+ IsMarking = false ;
168+ }
169+ }
170+
135171 private async void MarkAllAsRead ( )
136172 {
137173 // Make sure theres some sort of notification
0 commit comments