2121using Rothko ;
2222using System . Collections . ObjectModel ;
2323using GitHub . Collections ;
24+ using GitHub . UI ;
2425
2526namespace GitHub . ViewModels
2627{
@@ -64,21 +65,23 @@ public RepositoryCloneViewModel(
6465 this . usageTracker = usageTracker ;
6566
6667 Title = string . Format ( CultureInfo . CurrentCulture , Resources . CloneTitle , repositoryHost . Title ) ;
68+ IsLoading = true ;
6769
68- var col = new TrackingCollection < IRepositoryModel > ( filter : FilterRepository ) ;
69- col = repositoryHost . ModelService . GetRepositories ( col ) as TrackingCollection < IRepositoryModel > ;
70- col . OriginalCompleted . Subscribe (
71- _ => { }
70+ Repositories = new TrackingCollection < IRepositoryModel > ( ) ;
71+ repositories . ProcessingDelay = TimeSpan . Zero ;
72+ repositories . Comparer = OrderedComparer < IRepositoryModel > . OrderBy ( x => x . Owner ) . ThenBy ( x => x . Name ) . Compare ;
73+ repositories . Filter = FilterRepository ;
74+ repositories . NewerComparer = OrderedComparer < IRepositoryModel > . OrderByDescending ( x => x . UpdatedAt ) . Compare ;
75+
76+ repositories . OriginalCompleted . Subscribe (
77+ _ => { }
7278 , ex =>
73- {
74- LoadingFailed = true ;
75- log . Error ( "Error while loading repositories" , ex ) ;
76- } ,
79+ {
80+ LoadingFailed = true ;
81+ log . Error ( "Error while loading repositories" , ex ) ;
82+ } ,
7783 ( ) => IsLoading = false
7884 ) ;
79- col . Subscribe ( _ => IsLoading = true , ( ) => { } ) ;
80-
81- Repositories = col ;
8285
8386 filterTextIsEnabled = this . WhenAny ( x => x . Repositories . Count , x => x . Value > 0 )
8487 . ToProperty ( this , x => x . FilterTextIsEnabled ) ;
@@ -90,7 +93,7 @@ public RepositoryCloneViewModel(
9093 this . WhenAny ( x => x . FilterText , x => x . Value )
9194 . DistinctUntilChanged ( StringComparer . OrdinalIgnoreCase )
9295 . Throttle ( TimeSpan . FromMilliseconds ( 100 ) , RxApp . MainThreadScheduler )
93- . Subscribe ( _ => col . Filter = FilterRepository ) ;
96+ . Subscribe ( _ => repositories . Filter = FilterRepository ) ;
9497
9598 var baseRepositoryPath = this . WhenAny (
9699 x => x . BaseRepositoryPath ,
@@ -214,14 +217,14 @@ public string BaseRepositoryPath
214217 /// </summary>
215218 public IReactiveCommand < Unit > CloneCommand { get ; private set ; }
216219
217- ObservableCollection < IRepositoryModel > repositories ;
220+ TrackingCollection < IRepositoryModel > repositories ;
218221 /// <summary>
219222 /// List of repositories as returned by the server
220223 /// </summary>
221224 public ObservableCollection < IRepositoryModel > Repositories
222225 {
223226 get { return repositories ; }
224- private set { this . RaiseAndSetIfChanged ( ref repositories , value ) ; }
227+ private set { repositories = value as TrackingCollection < IRepositoryModel > ; this . RaisePropertyChanged ( ) ; }
225228 }
226229
227230 IRepositoryModel selectedRepository ;
0 commit comments