Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(GH-769) Prevent automatic outdated package check #771

Merged
merged 4 commits into from
May 18, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,16 @@ public bool CanExportAll()
return _exportAll;
}

public bool CanCheckForUpdate()
{
return HasLoaded && !IsLoading;
}

public async void CheckForUpdate()
{
await CheckOutdated();
}

public bool CanRefreshPackages()
{
return HasLoaded && !IsLoading;
Expand Down Expand Up @@ -405,26 +415,41 @@ private async Task LoadPackages()
return;
}

IsLoading = true;
IsShowOnlyPackagesWithUpdateEnabled = !_configService.GetAppConfiguration().PreventAutomatedOutdatedPackagesCheck;

IsShowOnlyPackagesWithUpdateEnabled = false;
_packages.Clear();
Packages.Clear();

try
var packages = (await _chocolateyService.GetInstalledPackages())
.Select(Mapper.Map<IPackageViewModel>).ToList();

foreach (var packageViewModel in packages)
{
_packages.Clear();
Packages.Clear();
_packages.Add(packageViewModel);
Packages.Add(packageViewModel);
}

var packages = (await _chocolateyService.GetInstalledPackages())
.Select(Mapper.Map<IPackageViewModel>).ToList();
FirstLoadIncomplete = false;

foreach (var packageViewModel in packages)
{
_packages.Add(packageViewModel);
Packages.Add(packageViewModel);
}
if (!_configService.GetAppConfiguration().PreventAutomatedOutdatedPackagesCheck)
{
await CheckOutdated();
}
}

private async Task CheckOutdated()
{
if (IsLoading)
{
return;
}

FirstLoadIncomplete = false;
IsLoading = true;

IsShowOnlyPackagesWithUpdateEnabled = false;

try
{
var updates = await _chocolateyService.GetOutdatedPackages();
foreach (var update in updates)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,15 @@
IsEnabled="{Binding IsShowOnlyPackagesWithUpdateEnabled}"/>
</WrapPanel>
<StackPanel Grid.Column="1" Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="10,6">
<Button Command="{commands:DataContextCommandAdapter CheckForUpdate, CanCheckForUpdate}"
ToolTipService.ShowOnDisabled="True"
VerticalAlignment="Center"
Style="{DynamicResource IconFlatButtonStyle}" ToolTip="{x:Static properties:Resources.LocalSourceView_ButtonCheckUpdatePkgs}" Margin="0,0,2,0">
<StackPanel Orientation="Horizontal">
<iconPacks:PackIconFontAwesome Kind="SyncSolid" />
<iconPacks:PackIconFontAwesome Kind="BoxSolid" Margin="2 0 0 0" />
</StackPanel>
</Button>
<Button Command="{commands:DataContextCommandAdapter RefreshPackages, CanRefreshPackages}"
ToolTipService.ShowOnDisabled="True"
VerticalAlignment="Center"
Expand Down
4 changes: 4 additions & 0 deletions Source/ChocolateyGui.Common/Models/AppConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ public class AppConfiguration
[Feature]
public bool PreventPreload { get; set; }

[LocalizedDescription("SettingsView_TogglePreventAutomatedOutdatedPackagesCheckDescription")]
[Feature]
public bool PreventAutomatedOutdatedPackagesCheck { get; set; }

[LocalizedDescription("SettingsView_ToggleExcludeInstalledPackagesDescription")]
[Feature]
public bool ExcludeInstalledPackages { get; set; }
Expand Down
18 changes: 18 additions & 0 deletions Source/ChocolateyGui.Common/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions Source/ChocolateyGui.Common/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,9 @@ Error: {1}{2}</value>
<data name="LocalSourceView_ButtonRefreshPkgs" xml:space="preserve">
<value>Refresh Packages</value>
</data>
<data name="LocalSourceView_ButtonCheckUpdatePkgs" xml:space="preserve">
<value>Check for outdated packages</value>
</data>
<data name="LocalSourceView_ButtonUpdateAll" xml:space="preserve">
<value>Update All</value>
</data>
Expand Down Expand Up @@ -680,6 +683,9 @@ NOTE: Probably only necessary to change in RTL languages.</comment>
<data name="SettingsView_TogglePreventPreloadDescription" xml:space="preserve">
<value>Prevents preloading results with a blank search when opening the remote source view.</value>
</data>
<data name="SettingsView_TogglePreventAutomatedOutdatedPackagesCheckDescription" xml:space="preserve">
<value>Prevents automated check for outdated packages on startup.</value>
</data>
<data name="SourcesView_AggregatedSourcesId" xml:space="preserve">
<value>All Sources</value>
</data>
Expand Down
1 change: 1 addition & 0 deletions nuspec/chocolatey/ChocolateyGUI.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Chocolatey GUI is a delicious GUI on top of the Chocolatey command line tool.
- `/DefaultToTileViewForRemoteSource` - Enables/disables whether or not Chocolatey GUI defauls to tile instead of list view for all remote source views
- `/UseDelayedSearch` - Enables/disables whether or not Chocolatey GUI uses a live search, which returns results after a short delay without clicking the search button
- `/PreventPreload` - Prevents preloading results with a blank search when opening the remote source view.
- `/PreventAutomatedOutdatedPackagesCheck - Prevents automated check for outdated packages on startup.
- `/ExcludeInstalledPackages` - Enables/disables whether or not Chocolatey GUI shows packages that are already installed when viewing sources
- `/ShowAggregatedSourceView` - Enables/disables whether or not Chocolatey GUI shows an additional source combining all sources into one location
- `/ShowAdditionalPackageInformation` - Show additional package information on Local and Remote views.
Expand Down
4 changes: 4 additions & 0 deletions nuspec/chocolatey/helper.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ function Set-UserSettings {
Set-FeatureState "PreventPreload" ($pp.PreventPreload -eq $true)
}

if($pp.ContainsKey("PreventAutomatedOutdatedPackagesCheck")) {
Set-FeatureState "PreventAutomatedOutdatedPackagesCheck" ($pp.PreventAutomatedOutdatedPackagesCheck -eq $true)
}

if($pp.ContainsKey("ExcludeInstalledPackages")) {
Set-FeatureState "ExcludeInstalledPackages" ($pp.ExcludeInstalledPackages -eq $true)
}
Expand Down