@@ -37,8 +37,6 @@ public class PullRequestStatusBarManager
37
37
readonly Lazy < ITeamExplorerContext > teamExplorerContext ;
38
38
readonly Lazy < IConnectionManager > connectionManager ;
39
39
40
- IDisposable currentSessionSubscription ;
41
-
42
40
[ ImportingConstructor ]
43
41
public PullRequestStatusBarManager (
44
42
Lazy < IUsageTracker > usageTracker ,
@@ -68,41 +66,31 @@ public void StartShowingStatus()
68
66
{
69
67
try
70
68
{
71
- teamExplorerContext . Value . WhenAnyValue ( x => x . ActiveRepository )
69
+ var activeReposities = teamExplorerContext . Value . WhenAnyValue ( x => x . ActiveRepository ) ;
70
+ var sessions = pullRequestSessionManager . Value . WhenAnyValue ( x => x . CurrentSession ) ;
71
+ activeReposities
72
+ . CombineLatest ( sessions , ( r , s ) => ( r , s ) )
73
+ . Throttle ( TimeSpan . FromSeconds ( 1 ) )
72
74
. ObserveOn ( RxApp . MainThreadScheduler )
73
- . Subscribe ( x => RefreshActiveRepository ( x ) ) ;
75
+ . Subscribe ( x => RefreshCurrentSession ( x . r , x . s ) . Forget ( log ) ) ;
74
76
}
75
77
catch ( Exception e )
76
78
{
77
79
log . Error ( e , "Error initializing" ) ;
78
80
}
79
81
}
80
82
81
- void RefreshActiveRepository ( ILocalRepositoryModel repository )
82
- {
83
- currentSessionSubscription ? . Dispose ( ) ;
84
- currentSessionSubscription = pullRequestSessionManager . Value . WhenAnyValue ( x => x . CurrentSession )
85
- . Subscribe ( x => RefreshCurrentSession ( repository , x ) . Forget ( ) ) ;
86
- }
87
-
88
83
async Task RefreshCurrentSession ( ILocalRepositoryModel repository , IPullRequestSession session )
89
84
{
90
- try
91
- {
92
- var showStatus = await IsDotComOrEnterpriseRepository ( repository ) ;
93
- if ( ! showStatus )
94
- {
95
- ShowStatus ( null ) ;
96
- return ;
97
- }
98
-
99
- var viewModel = CreatePullRequestStatusViewModel ( session ) ;
100
- ShowStatus ( viewModel ) ;
101
- }
102
- catch ( Exception e )
85
+ var showStatus = await IsDotComOrEnterpriseRepository ( repository ) ;
86
+ if ( ! showStatus )
103
87
{
104
- log . Error ( e , nameof ( RefreshCurrentSession ) ) ;
88
+ ShowStatus ( null ) ;
89
+ return ;
105
90
}
91
+
92
+ var viewModel = CreatePullRequestStatusViewModel ( session ) ;
93
+ ShowStatus ( viewModel ) ;
106
94
}
107
95
108
96
async Task < bool > IsDotComOrEnterpriseRepository ( ILocalRepositoryModel repository )
0 commit comments