Skip to content

Commit

Permalink
Merge pull request #2677 from marticliment/fix-software-list-not-show…
Browse files Browse the repository at this point in the history
…ing-results

Fix certain packages not showing on software pages
  • Loading branch information
marticliment authored Aug 30, 2024
2 parents e8a5081 + d315078 commit 8a6483f
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 4 deletions.
27 changes: 26 additions & 1 deletion src/UniGetUI.Core.Tools.Tests/ToolsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public void TestSafeQueryString(string query, string expected)
}

[Fact]
public void TestEnvVariables()
public void TestEnvVariableCreation()
{
const string ENV1 = "NONEXISTENTENVVARIABLE";
Environment.SetEnvironmentVariable(ENV1, null, EnvironmentVariableTarget.Process);
Expand All @@ -160,5 +160,30 @@ public void TestEnvVariables()
newInfo2.Environment.TryGetValue(ENV1, out string? result3);
Assert.Null(result3);
}

[Fact]
public void TestEnvVariableReplacement()
{
const string ENV = "TMP";

var expected = Environment.GetEnvironmentVariable(ENV, EnvironmentVariableTarget.User);

ProcessStartInfo info = CoreTools.UpdateEnvironmentVariables();
info.Environment.TryGetValue(ENV, out string? result);
Assert.Equal(expected, result);
}

[Fact]
public void TestEnvVariableYuxtaposition()
{
const string ENV = "PATH";

var oldpath = Environment.GetEnvironmentVariable(ENV, EnvironmentVariableTarget.Machine) + ";" +
Environment.GetEnvironmentVariable(ENV, EnvironmentVariableTarget.User);

ProcessStartInfo info = CoreTools.UpdateEnvironmentVariables();
info.Environment.TryGetValue(ENV, out string? result);
Assert.Equal(oldpath, result);
}
}
}
11 changes: 10 additions & 1 deletion src/UniGetUI.Core.Tools/Tools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,16 @@ public static ProcessStartInfo UpdateEnvironmentVariables(ProcessStartInfo info)
}
foreach (DictionaryEntry env in Environment.GetEnvironmentVariables(EnvironmentVariableTarget.User))
{
info.Environment[env.Key.ToString()] = env.Value?.ToString();
string key = env.Key.ToString() ?? "";
string newValue = env.Value?.ToString() ?? "";
if (info.Environment.TryGetValue(key, out string? oldValue) && oldValue is not null && oldValue.Contains(';') && newValue != "")
{
info.Environment[key] = oldValue + ";" + newValue;
}
else
{
info.Environment[key] = newValue;
}
}
return info;
}
Expand Down
20 changes: 18 additions & 2 deletions src/UniGetUI/Interface/SoftwarePages/AbstractPackagesPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,13 @@ public void FilterPackages()
}
else if (RootNodeForManager.ContainsValue(node))
{
VisibleManagers.Add(RootNodeForManager.First(x => x.Value == node).Key);
IPackageManager manager = RootNodeForManager.First(x => x.Value == node).Key;
VisibleManagers.Add(manager);
if (manager.Capabilities.SupportsCustomSources)
{
foreach (IManagerSource source in manager.SourceFactory.GetAvailableSources())
if (!VisibleSources.Contains(source)) VisibleSources.Add(source);
}
}
}
}
Expand Down Expand Up @@ -568,8 +574,8 @@ public void FilterPackages()
}
FilteredPackages.BlockSorting = false;
FilteredPackages.Sort();
PackageList.InvalidateArrange();
UpdatePackageCount();
ForceRedrawByScroll();
}

/// <summary>
Expand Down Expand Up @@ -793,5 +799,15 @@ private void SelectAllCheckBox_ValueChanged(object sender, RoutedEventArgs e)
FilteredPackages.ClearSelection();
}
}

private async void ForceRedrawByScroll()
{
if (PackageList is not null)
{
PackageList.ScrollView?.ScrollTo(0, 1);
await Task.Delay(10);
PackageList.ScrollView?.ScrollTo(0, 0);
}
}
}
}

0 comments on commit 8a6483f

Please sign in to comment.