Skip to content

Commit fb9d630

Browse files
committed
Fix search term being null
1 parent fd12fd4 commit fb9d630

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

SporeCommunity.ModBrowser.Blazor/Pages/Index.razor

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<MainNavButtons />
55

66
<form @onsubmit="@ExecuteSearch">
7-
<input @bind="searchTerm" placeholder="Search for mods">
7+
<input @bind="SearchTerm" placeholder="Search for mods">
88
<button type="submit">Search</button>
99
</form>
1010

@@ -40,18 +40,13 @@ else
4040
private GithubModSearchEngine github = new("Spore-Community/ModBrowser");
4141

4242
[SupplyParameterFromQuery(Name = "search")]
43-
private string searchTerm { get; set; } = "";
43+
private string SearchTerm { get => _searchTerm; set => _searchTerm = value ?? ""; }
44+
private string _searchTerm = "";
4445

4546
private List<ModListing> mods = new();
4647

4748
protected override async Task OnInitializedAsync()
4849
{
49-
// If the search term is empty, we want to list all mods
50-
if(string.IsNullOrWhiteSpace(searchTerm))
51-
{
52-
searchTerm = "";
53-
}
54-
5550
await ExecuteSearch();
5651
}
5752

@@ -61,12 +56,12 @@ else
6156
mods.Clear();
6257
try
6358
{
64-
await foreach (var mod in github.SearchModsAsync(searchTerm))
59+
await foreach (var mod in github.SearchModsAsync(SearchTerm))
6560
{
6661
mods.Add(mod);
6762

6863
// When listing all mods, sort by download count
69-
if (searchTerm.Length == 0)
64+
if (SearchTerm.Length == 0)
7065
{
7166
mods = mods.OrderByDescending(mod => mod.DownloadCount).ToList();
7267
}

0 commit comments

Comments
 (0)