Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit fd29190

Browse files
authored
Merge pull request #944 from github/fixes/843-pr-list-filters
Fix PR list filters
2 parents 8953293 + 5845a60 commit fd29190

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

src/GitHub.App/ViewModels/PullRequestListViewModel.cs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public class PullRequestListViewModel : PanePageViewModelBase, IPullRequestListV
3131
readonly TrackingCollection<IAccount> trackingAssignees;
3232
readonly IPackageSettings settings;
3333
readonly PullRequestListUIState listSettings;
34+
readonly bool constructing;
3435

3536
[ImportingConstructor]
3637
PullRequestListViewModel(
@@ -46,6 +47,7 @@ public PullRequestListViewModel(
4647
ILocalRepositoryModel repository,
4748
IPackageSettings settings)
4849
{
50+
constructing = true;
4951
this.repositoryHost = repositoryHost;
5052
this.repository = repository;
5153
this.settings = settings;
@@ -81,18 +83,20 @@ public PullRequestListViewModel(
8183
.Subscribe(s => UpdateFilter(s, SelectedAssignee, SelectedAuthor));
8284

8385
this.WhenAny(x => x.SelectedAssignee, x => x.Value)
84-
.Where(x => PullRequests != null && x != EmptyUser && !IsBusy)
86+
.Where(x => PullRequests != null && x != EmptyUser)
8587
.Subscribe(a => UpdateFilter(SelectedState, a, SelectedAuthor));
8688

8789
this.WhenAny(x => x.SelectedAuthor, x => x.Value)
88-
.Where(x => PullRequests != null && x != EmptyUser && !IsBusy)
90+
.Where(x => PullRequests != null && x != EmptyUser)
8991
.Subscribe(a => UpdateFilter(SelectedState, SelectedAssignee, a));
9092

9193
SelectedState = States.FirstOrDefault(x => x.Name == listSettings.SelectedState) ?? States[0];
9294
OpenPullRequest = ReactiveCommand.Create();
9395
OpenPullRequest.Subscribe(DoOpenPullRequest);
9496
CreatePullRequest = ReactiveCommand.Create();
9597
CreatePullRequest.Subscribe(_ => DoCreatePullRequest());
98+
99+
constructing = false;
96100
}
97101

98102
public override void Initialize([AllowNull] ViewWithData data)
@@ -146,6 +150,7 @@ void UpdateFilter(PullRequestState state, [AllowNull]IAccount ass, [AllowNull]IA
146150
(!state.IsOpen.HasValue || state.IsOpen == pr.IsOpen) &&
147151
(ass == null || ass.Equals(pr.Assignee)) &&
148152
(aut == null || aut.Equals(pr.Author));
153+
SaveSettings();
149154
}
150155

151156
bool isBusy;
@@ -240,7 +245,6 @@ protected void Dispose(bool disposing)
240245
pullRequests.Dispose();
241246
trackingAuthors.Dispose();
242247
trackingAssignees.Dispose();
243-
SaveSettings();
244248
disposed = true;
245249
}
246250
}
@@ -253,10 +257,13 @@ public void Dispose()
253257

254258
void SaveSettings()
255259
{
256-
listSettings.SelectedState = SelectedState.Name;
257-
listSettings.SelectedAssignee = SelectedAssignee?.Login;
258-
listSettings.SelectedAuthor = SelectedAuthor?.Login;
259-
settings.Save();
260+
if (!constructing)
261+
{
262+
listSettings.SelectedState = SelectedState.Name;
263+
listSettings.SelectedAssignee = SelectedAssignee?.Login;
264+
listSettings.SelectedAuthor = SelectedAuthor?.Login;
265+
settings.Save();
266+
}
260267
}
261268

262269
void DoOpenPullRequest(object pullRequest)

src/GitHub.VisualStudio/UI/Views/PullRequestListView.xaml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,23 +115,20 @@
115115

116116
<WrapPanel Grid.Column="0" HorizontalAlignment="Stretch">
117117

118-
<ui:LinkDropDown IsEnabled="{Binding IsBusy, Converter={ui:InverseBooleanConverter}}"
119-
ItemsSource="{Binding States}"
118+
<ui:LinkDropDown ItemsSource="{Binding States}"
120119
SelectedItem="{Binding SelectedState}"
121120
AutomationProperties.AutomationId="{x:Static automation:AutomationIDs.PullRequestListStatusFilterComboBox}" />
122121

123122
<Separator Style="{StaticResource VerticalSeparator}" />
124123

125124
<ui:LinkDropDown Header="Assignee"
126-
IsEnabled="{Binding IsBusy, Converter={ui:InverseBooleanConverter}}"
127125
ItemsSource="{Binding Source={StaticResource AssigneeCollectionViewSource}}"
128126
SelectedItem="{Binding SelectedAssignee}"
129127
AutomationProperties.AutomationId="{x:Static automation:AutomationIDs.PullRequestListAssigneeFilterComboBox}"/>
130128

131129
<Separator Style="{StaticResource VerticalSeparator}" />
132130

133131
<ui:LinkDropDown Header="Author"
134-
IsEnabled="{Binding IsBusy, Converter={ui:InverseBooleanConverter}}"
135132
ItemsSource="{Binding Source={StaticResource AuthorCollectionViewSource}}"
136133
SelectedItem="{Binding SelectedAuthor}"
137134
AutomationProperties.AutomationId="{x:Static automation:AutomationIDs.PullRequestListAuthorFilterComboBox}" />

0 commit comments

Comments
 (0)