Skip to content

Commit a6e78eb

Browse files
committed
(GH-602) Initial attempt at getting things working
1 parent aedf5b1 commit a6e78eb

19 files changed

+191
-72
lines changed

Source/ChocolateyGui.Common.Windows/Services/ChocolateyService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public async Task<IEnumerable<Package>> GetInstalledPackages()
9595

9696
public async Task<IReadOnlyList<OutdatedPackage>> GetOutdatedPackages(bool includePrerelease = false, string packageName = null, bool forceCheckForOutdatedPackages = false)
9797
{
98-
var preventAutomatedOutdatedPackagesCheck = _configService.GetAppConfiguration().PreventAutomatedOutdatedPackagesCheck;
98+
var preventAutomatedOutdatedPackagesCheck = _configService.GetAppConfiguration().PreventAutomatedOutdatedPackagesCheck ?? false;
9999

100100
if (preventAutomatedOutdatedPackagesCheck && !forceCheckForOutdatedPackages)
101101
{

Source/ChocolateyGui.Common.Windows/Startup/ChocolateyGuiModule.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,11 @@ protected override void Load(ContainerBuilder builder)
109109

110110
try
111111
{
112-
var database = new LiteDatabase($"filename={Path.Combine(Bootstrapper.LocalAppDataPath, "data.db")};upgrade=true");
113-
builder.Register(c => database).SingleInstance();
112+
var userDatabase = new LiteDatabase($"filename={Path.Combine(Bootstrapper.LocalAppDataPath, "data.db")};upgrade=true");
113+
var globalDatabase = new LiteDatabase($"filename={Path.Combine(Bootstrapper.AppDataPath, "config", "data.db")};upgrade=true");
114+
115+
builder.RegisterInstance(new ConfigService(globalDatabase, userDatabase)).As<IConfigService>().SingleInstance();
116+
builder.RegisterInstance(new LiteDBFileStorageService(userDatabase)).As<IFileStorageService>().SingleInstance();
114117
}
115118
catch (IOException ex)
116119
{

Source/ChocolateyGui.Common.Windows/ViewModels/Items/PackageViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ public bool IsDownloadCountAvailable
375375
{
376376
get
377377
{
378-
return DownloadCount != -1 && !_configService.GetAppConfiguration().HidePackageDownloadCount;
378+
return DownloadCount != -1 && !(_configService.GetAppConfiguration().HidePackageDownloadCount ?? false);
379379
}
380380
}
381381

Source/ChocolateyGui.Common.Windows/ViewModels/LocalSourceViewModel.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -323,19 +323,19 @@ protected override async void OnInitialize()
323323
return;
324324
}
325325

326-
ListViewMode = _configService.GetAppConfiguration().DefaultToTileViewForLocalSource ? ListViewMode.Tile : ListViewMode.Standard;
327-
ShowAdditionalPackageInformation = _configService.GetAppConfiguration().ShowAdditionalPackageInformation;
326+
ListViewMode = _configService.GetAppConfiguration().DefaultToTileViewForLocalSource ?? false ? ListViewMode.Tile : ListViewMode.Standard;
327+
ShowAdditionalPackageInformation = _configService.GetAppConfiguration().ShowAdditionalPackageInformation ?? false;
328328

329329
Observable.FromEventPattern<EventArgs>(_configService, "SettingsChanged")
330330
.ObserveOnDispatcher()
331331
.Subscribe(eventPattern =>
332332
{
333333
var appConfig = (AppConfiguration)eventPattern.Sender;
334334

335-
ListViewMode = appConfig.DefaultToTileViewForLocalSource
335+
ListViewMode = appConfig.DefaultToTileViewForLocalSource ?? false
336336
? ListViewMode.Tile
337337
: ListViewMode.Standard;
338-
ShowAdditionalPackageInformation = appConfig.ShowAdditionalPackageInformation;
338+
ShowAdditionalPackageInformation = appConfig.ShowAdditionalPackageInformation ?? false;
339339
});
340340

341341
await LoadPackages();
@@ -472,7 +472,7 @@ private async Task CheckOutdated(bool forceCheckForOutdated)
472472
// outdated packages. We should only enable the checkbox here when: (or)
473473
// 1. the "Prevent Automated Outdated Packages Check" is disabled
474474
// 2. forced a check for outdated packages.
475-
IsShowOnlyPackagesWithUpdateEnabled = !_configService.GetAppConfiguration().PreventAutomatedOutdatedPackagesCheck || forceCheckForOutdated;
475+
IsShowOnlyPackagesWithUpdateEnabled = !_configService.GetAppConfiguration().PreventAutomatedOutdatedPackagesCheck ?? false || forceCheckForOutdated;
476476

477477
// Force invalidating the command stuff.
478478
// This helps us to prevent disabled buttons after executing this routine.

Source/ChocolateyGui.Common.Windows/ViewModels/RemoteSourceViewModel.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ public async Task LoadPackages(bool forceCheckForOutdatedPackages)
249249
return;
250250
}
251251

252-
if (!HasLoaded && _configService.GetAppConfiguration().PreventPreload)
252+
if (!HasLoaded && (_configService.GetAppConfiguration().PreventPreload ?? false))
253253
{
254254
ShowShouldPreventPreloadMessage = true;
255255
HasLoaded = true;
@@ -299,7 +299,7 @@ public async Task LoadPackages(bool forceCheckForOutdatedPackages)
299299
Packages.Add(Mapper.Map<IPackageViewModel>(p));
300300
});
301301

302-
if (_configService.GetAppConfiguration().ExcludeInstalledPackages)
302+
if (_configService.GetAppConfiguration().ExcludeInstalledPackages ?? false)
303303
{
304304
Packages.RemoveAll(x => x.IsInstalled);
305305
}
@@ -347,8 +347,8 @@ protected override void OnInitialize()
347347
{
348348
try
349349
{
350-
ListViewMode = _configService.GetAppConfiguration().DefaultToTileViewForLocalSource ? ListViewMode.Tile : ListViewMode.Standard;
351-
ShowAdditionalPackageInformation = _configService.GetAppConfiguration().ShowAdditionalPackageInformation;
350+
ListViewMode = _configService.GetAppConfiguration().DefaultToTileViewForLocalSource ?? false ? ListViewMode.Tile : ListViewMode.Standard;
351+
ShowAdditionalPackageInformation = _configService.GetAppConfiguration().ShowAdditionalPackageInformation ?? false;
352352

353353
Observable.FromEventPattern<EventArgs>(_configService, "SettingsChanged")
354354
.ObserveOnDispatcher()
@@ -357,13 +357,13 @@ protected override void OnInitialize()
357357
var appConfig = (AppConfiguration)eventPattern.Sender;
358358

359359
_searchQuerySubscription?.Dispose();
360-
if (appConfig.UseDelayedSearch)
360+
if (appConfig.UseDelayedSearch ?? false)
361361
{
362362
SubscribeToLoadPackagesOnSearchQueryChange();
363363
}
364364

365-
ListViewMode = appConfig.DefaultToTileViewForRemoteSource ? ListViewMode.Tile : ListViewMode.Standard;
366-
ShowAdditionalPackageInformation = appConfig.ShowAdditionalPackageInformation;
365+
ListViewMode = appConfig.DefaultToTileViewForRemoteSource ?? false ? ListViewMode.Tile : ListViewMode.Standard;
366+
ShowAdditionalPackageInformation = appConfig.ShowAdditionalPackageInformation ?? false;
367367
});
368368

369369
#pragma warning disable 4014
@@ -375,7 +375,7 @@ protected override void OnInitialize()
375375
"IncludeAllVersions", "IncludePrerelease", "MatchWord", "SortSelection"
376376
};
377377

378-
if (_configService.GetAppConfiguration().UseDelayedSearch)
378+
if (_configService.GetAppConfiguration().UseDelayedSearch ?? false)
379379
{
380380
SubscribeToLoadPackagesOnSearchQueryChange();
381381
}

Source/ChocolateyGui.Common.Windows/ViewModels/SettingsViewModel.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ private async void OnActivated(object sender, ActivationEventArgs activationEven
443443
.Concat()
444444
.Subscribe();
445445

446-
var chocolateyGuiFeatures = _configService.GetFeatures();
446+
var chocolateyGuiFeatures = _configService.GetFeatures(global: false);
447447
foreach (var chocolateyGuiFeature in chocolateyGuiFeatures)
448448
{
449449
ChocolateyGuiFeatures.Add(chocolateyGuiFeature);
@@ -455,7 +455,7 @@ private async void OnActivated(object sender, ActivationEventArgs activationEven
455455
.Concat()
456456
.Subscribe();
457457

458-
var chocolateyGuiSettings = _configService.GetSettings();
458+
var chocolateyGuiSettings = _configService.GetSettings(global: false);
459459
foreach (var chocolateyGuiSetting in chocolateyGuiSettings)
460460
{
461461
ChocolateyGuiSettings.Add(chocolateyGuiSetting);

Source/ChocolateyGui.Common.Windows/ViewModels/ShellViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ protected override void OnInitialize()
153153

154154
private bool CanGoToSource(object obj)
155155
{
156-
if (!_configService.GetAppConfiguration().UseKeyboardBindings)
156+
if (!_configService.GetAppConfiguration().UseKeyboardBindings ?? true)
157157
{
158158
return false;
159159
}

Source/ChocolateyGui.Common.Windows/ViewModels/SourcesViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public async Task LoadSources()
9090
var sources = await _packageService.GetSources();
9191
var vms = new List<ISourceViewModelBase>();
9292

93-
if (_configService.GetAppConfiguration().ShowAggregatedSourceView)
93+
if (_configService.GetAppConfiguration().ShowAggregatedSourceView ?? false)
9494
{
9595
vms.Add(_remoteSourceVmFactory(new ChocolateyAggregatedSources()));
9696
vms.Add(new SourceSeparatorViewModel());

Source/ChocolateyGui.Common.Windows/Views/ShellView.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public Task<ChocolateyDialogController> ShowChocolateyDialogAsync(
9696
return Dispatcher.Invoke(async () =>
9797
{
9898
// create the dialog control
99-
var dialog = new ChocolateyDialog(this, _configService.GetAppConfiguration().ShowConsoleOutput)
99+
var dialog = new ChocolateyDialog(this, _configService.GetAppConfiguration().ShowConsoleOutput ?? false)
100100
{
101101
Title = title,
102102
IsCancelable = isCancelable,

Source/ChocolateyGui.Common/Commands/ConfigCommand.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,11 @@ public virtual void ConfigureArgumentParser(OptionSet optionSet, ChocolateyGuiCo
3939
.Add(
4040
"value=",
4141
Resources.ConfigCommand_ValueOption,
42-
option => configuration.ConfigCommand.ConfigValue = option.remove_surrounding_quotes());
42+
option => configuration.ConfigCommand.ConfigValue = option.remove_surrounding_quotes())
43+
.Add(
44+
"g|global",
45+
Resources.ConfigCommand_GlobalOption,
46+
option => configuration.ConfigCommand.Global = option != null);
4347
}
4448

4549
public virtual void HandleAdditionalArgumentParsing(IList<string> unparsedArguments, ChocolateyGuiConfiguration configuration)

0 commit comments

Comments
 (0)