-
Notifications
You must be signed in to change notification settings - Fork 21
feat: Add the option to disable codescan #245
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
base: develop
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -48,11 +48,20 @@ public bool? TTSEnabled | |
| get => _TTSEnabled; | ||
| set => this.RaiseAndSetIfChanged(ref _TTSEnabled, value); | ||
| } | ||
|
|
||
| private bool? _enableCodeScan = true; | ||
|
|
||
| public bool? EnableCodeScan | ||
| { | ||
| get => _enableCodeScan; | ||
| set => this.RaiseAndSetIfChanged(ref _enableCodeScan, value); | ||
| } | ||
|
|
||
| private readonly IPreferencesService _preferencesService; | ||
| private readonly IInstallationService _installationService; | ||
| private readonly IEnvironmentService _environmentService; | ||
| private readonly ITTSService _ttsService; | ||
|
|
||
|
|
||
| public PreferencesPanelViewModel( | ||
| IPreferencesService preferencesService, | ||
|
|
@@ -69,6 +78,7 @@ public PreferencesPanelViewModel( | |
| _installationPath = preferences.InstallationPath; | ||
| _autoRemove = preferences.AutoRemove; | ||
| _TTSEnabled = preferences.TTSEnabled; | ||
| _enableCodeScan = preferences.EnableCodeScan; | ||
| this.WhenAnyValue(p => p.AutoRemove) | ||
| .Select(_ => Observable.FromAsync(OnAutoRemoveChangedAsync)) | ||
| .Concat() | ||
|
|
@@ -78,6 +88,11 @@ public PreferencesPanelViewModel( | |
| .Select(_ => Observable.FromAsync(OnTTSChangedAsync)) | ||
| .Concat() | ||
| .Subscribe(); | ||
|
|
||
| this.WhenAnyValue(p => p.EnableCodeScan) | ||
| .Select(_ => Observable.FromAsync(OnAllowCodeScanChangedAsync)) | ||
| .Concat() | ||
| .Subscribe(); | ||
| } | ||
|
|
||
| public async Task OnAutoRemoveChangedAsync() | ||
|
|
@@ -160,6 +175,26 @@ await MessageBoxBuilder.CreateMessageBox(MessageBoxButtons.Ok, "Error moving ins | |
| await MessageBoxBuilder.CreateMessageBox(MessageBoxButtons.Ok, "Invalid installation path", invalidReason).ShowAsync(); | ||
| } | ||
| } | ||
|
|
||
| public async Task OnAllowCodeScanChangedAsync() | ||
| { | ||
| if (EnableCodeScan == false) | ||
| { | ||
| IMsBox<string> msgBox = MessageBoxBuilder.CreateMessageBox( | ||
| MessageBoxButtons.YesNo, | ||
| "Warning", | ||
| "For security reasons, we recommend you never disable the codescan feature unless you're trying to play on older servers that are no longer supported.\n Are you sure you want to proceed?" | ||
|
||
| ); | ||
|
|
||
| string response = await msgBox.ShowAsync(); | ||
| if (response.Equals(MessageBoxResults.No)) | ||
| { | ||
| EnableCodeScan = true; // Revert the change | ||
| } | ||
| } | ||
|
|
||
| _preferencesService.GetPreferences().EnableCodeScan = EnableCodeScan; | ||
| } | ||
|
|
||
| public override void Refresh() | ||
| { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is
envieronmentServicebeing injected now? I'm not familiar with this codebase. Where was it getting it from before?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think almost all pages use
envieronmentServicefor one reason or another. I've just decided to make this function static and public, so I don't have to rewrite this logic elsewhere.