66using ReactiveUI ;
77using GitHub . Services ;
88using System . Reactive . Linq ;
9- using System . Collections . ObjectModel ;
109using GitHub . Extensions . Reactive ;
1110using GitHub . UI ;
1211using System . Linq ;
13- using System . Windows . Input ;
1412using GitHub . Validation ;
1513using GitHub . Extensions ;
1614using NullGuard ;
17- using System . Reactive . Disposables ;
1815
1916namespace GitHub . ViewModels
2017{
@@ -24,7 +21,6 @@ public class PullRequestCreationViewModel : BaseViewModel, IPullRequestCreationV
2421 {
2522 readonly IRepositoryHost repositoryHost ;
2623 readonly ISimpleRepositoryModel activeRepo ;
27- readonly CompositeDisposable disposables = new CompositeDisposable ( ) ;
2824
2925 [ ImportingConstructor ]
3026 PullRequestCreationViewModel (
@@ -52,7 +48,6 @@ public PullRequestCreationViewModel(IRepositoryHost repositoryHost, ISimpleRepos
5248 var titleObs = this . WhenAny ( x => x . PRTitle , x => x . Value ) ;
5349 TitleValidator = ReactivePropertyValidator . ForObservable ( titleObs )
5450 . IfNullOrEmpty ( "Please enter a title for the Pull Request" ) ;
55- disposables . Add ( TitleValidator ) ;
5651
5752 var branchObs = this . WhenAny (
5853 x => x . SourceBranch ,
@@ -61,18 +56,16 @@ public PullRequestCreationViewModel(IRepositoryHost repositoryHost, ISimpleRepos
6156 BranchValidator = ReactivePropertyValidator . ForObservable ( branchObs )
6257 . IfTrue ( x => x == null , "Source branch doesn't exist remotely, have you pushed it?" )
6358 . IfTrue ( x => x . Name == TargetBranch . Name , "Source and target branch cannot be the same" ) ;
64- disposables . Add ( BranchValidator ) ;
6559
6660 var whenAnyValidationResultChanges = this . WhenAny (
6761 x => x . TitleValidator . ValidationResult ,
6862 x => x . BranchValidator . ValidationResult ,
6963 ( x , y ) => ( x . Value ? . IsValid ?? false ) && ( y . Value ? . IsValid ?? false ) ) ;
7064
71- disposables . Add (
72- this . WhenAny ( x => x . BranchValidator . ValidationResult , x => x . GetValue ( ) )
73- . WhereNotNull ( )
74- . Where ( x => ! x . IsValid && x . DisplayValidationError )
75- . Subscribe ( x => notifications . ShowError ( BranchValidator . ValidationResult . Message ) ) ) ;
65+ this . WhenAny ( x => x . BranchValidator . ValidationResult , x => x . GetValue ( ) )
66+ . WhereNotNull ( )
67+ . Where ( x => ! x . IsValid && x . DisplayValidationError )
68+ . Subscribe ( x => notifications . ShowError ( BranchValidator . ValidationResult . Message ) ) ;
7669
7770 createPullRequest = ReactiveCommand . CreateAsyncObservable ( whenAnyValidationResultChanges ,
7871 _ => service . CreatePullRequest ( repositoryHost , activeRepo , PRTitle , SourceBranch , TargetBranch )
@@ -83,7 +76,6 @@ public PullRequestCreationViewModel(IRepositoryHost repositoryHost, ISimpleRepos
8376 {
8477 }
8578 } ) ;
86- disposables . Add ( createPullRequest ) ;
8779 }
8880
8981 public override void Initialize ( [ AllowNull ] ViewWithData data )
0 commit comments