Skip to content

Commit

Permalink
Fix few more null checks/refs
Browse files Browse the repository at this point in the history
  • Loading branch information
U-C-S committed Aug 25, 2024
1 parent 52f60f3 commit 3649eef
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Source/Hurl.Library/Models/Ruleset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class Ruleset
[JsonIgnore]
public Guid Id { get; set; } = Guid.NewGuid();

public List<string> Rules { get; set; }
public List<string> Rules { get; set; } = [];

public string RulesetName { get; set; }

Expand Down
13 changes: 6 additions & 7 deletions Source/Hurl.Settings/ViewModels/StoreRulesetViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class StoreRulesetViewModel : ObservableObject
public StoreRulesetViewModel()
{
Id = Guid.NewGuid();
Browsers = State.Settings.GetBrowsers()
Browsers = State.Settings.Browsers
.Select(x => x.Name)
.ToList();
Rules = [];
Expand All @@ -30,7 +30,7 @@ public StoreRulesetViewModel()
public StoreRulesetViewModel(Ruleset set)
{
Id = set.Id;
Browsers = State.Settings.GetBrowsers()
Browsers = State.Settings.Browsers
.Select(x => x.Name)
.ToList();
Name = set?.RulesetName;
Expand All @@ -44,9 +44,9 @@ public StoreRulesetViewModel(Ruleset set)
if (set?.AltLaunchIndex is int altLaunchIndex)
{
List<string> altLaunchList = ["< None >"];
var x = State.Settings.GetBrowsers()[SelectedBrowser]
.AlternateLaunches
.Select(x => x.ItemName)
var x = State.Settings.Browsers[SelectedBrowser]
?.AlternateLaunches
?.Select(x => x.ItemName)
.ToList();
altLaunchList.AddRange(x);
AltLaunches = altLaunchList;
Expand Down Expand Up @@ -101,8 +101,7 @@ public Ruleset ToRuleSet()
{
Id = Id,
RulesetName = Name ?? "",
// TODO: dont do this, do proper validation
BrowserName = Browsers.ElementAtOrDefault(SelectedBrowser),
BrowserName = Browsers[SelectedBrowser],
Rules = Rules.Select(x => x.ToString()).ToList(),
AltLaunchIndex = SelectedAltLaunch > 0 ? SelectedAltLaunch - 1 : null
};
Expand Down
6 changes: 3 additions & 3 deletions Source/Hurl.Settings/Views/RulesetPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,20 +133,20 @@ private async void ViewRuleset(object sender, RoutedEventArgs e)

private void ClickMoveUpRuleset(object sender, RoutedEventArgs e)
{
var Id = (Guid)(sender as MenuFlyoutItem).Tag;
var Id = (Guid)(sender as MenuFlyoutItem)!.Tag;

ViewModel.MoveRulesetUp(Id);
}
private void ClickMoveDownRuleset(object sender, RoutedEventArgs e)
{
var Id = (Guid)(sender as MenuFlyoutItem).Tag;
var Id = (Guid)(sender as MenuFlyoutItem)!.Tag;

ViewModel.MoveRulesetDown(Id);
}

private void ClickDeleteRuleset(object sender, RoutedEventArgs e)
{
var Id = (Guid)(sender as MenuFlyoutItem).Tag;
var Id = (Guid)(sender as MenuFlyoutItem)!.Tag;

ViewModel.DeleteRuleset(Id);
}
Expand Down

0 comments on commit 3649eef

Please sign in to comment.