Skip to content

Commit 9393fd0

Browse files
committed
Fix a bug that packages were not loaded
1 parent 48c09ac commit 9393fd0

File tree

4 files changed

+32
-23
lines changed

4 files changed

+32
-23
lines changed

src/HandyWinget/Assets/Enums/IdentifyPackageMode.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ public enum IdentifyPackageMode
99
[Description("Off (Fast)")]
1010
Off,
1111

12-
[Description("Internal Method (Normal)")]
12+
[Description("Internal Method")]
1313
Internal,
1414

15-
[Description("Winget-cli Method (Slow)")]
15+
[Description("Winget-cli Method")]
1616
Wingetcli
1717
}
1818
}

src/HandyWinget/Assets/ISettings.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public class ISettings : JsonSettings
2222
public virtual bool GroupByPublisher { get; set; } = false;
2323
public virtual DataGridRowDetailsVisibilityMode ShowExtraDetails { get; set; } = DataGridRowDetailsVisibilityMode.Collapsed;
2424
public virtual NavigationViewPaneDisplayMode PaneDisplayMode { get; set; } = NavigationViewPaneDisplayMode.Top;
25-
public virtual InstallMode InstallMode { get; set; } = InstallMode.Wingetcli;
25+
public virtual InstallMode InstallMode { get; set; } = InstallMode.Internal;
2626
public virtual IdentifyPackageMode IdentifyPackageMode { get; set; } = IdentifyPackageMode.Off;
2727
public virtual ApplicationTheme Theme { get; set; } = ApplicationTheme.Light;
2828
public virtual Brush Accent { get; set; }

src/HandyWinget/MainWindow.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ private void OpenTerminal_Click(object sender, RoutedEventArgs e)
145145

146146
private void appBarRefresh_Click(object sender, RoutedEventArgs e)
147147
{
148-
Packages.Instance.LoadManifests(true);
148+
Packages.Instance.DownloadManifests(true);
149149
}
150150

151151
private void appBarExport_Click(object sender, RoutedEventArgs e)

src/HandyWinget/Views/Packages.xaml.cs

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ public Packages()
5050
BindingOperations.EnableCollectionSynchronization(DataList, Lock);
5151
BindingOperations.EnableCollectionSynchronization(_temoList, Lock);
5252
BindingOperations.EnableCollectionSynchronization(_tempVersions, Lock);
53-
LoadManifests();
54-
InitSettings();
53+
DownloadManifests();
54+
SetDataListGrouping();
5555
}
5656

57-
private void InitSettings()
57+
private void SetDataListGrouping()
5858
{
5959
dataGrid.RowDetailsVisibilityMode = Settings.ShowExtraDetails;
6060

@@ -69,11 +69,8 @@ private void InitSettings()
6969
}
7070
}
7171

72-
public async void LoadManifests(bool IsRefresh = false)
72+
public async void DownloadManifests(bool IsRefresh = false)
7373
{
74-
int _totalmanifestsCount = 0;
75-
int _currentManifestCount = 0;
76-
7774
DataList?.Clear();
7875
_temoList?.Clear();
7976
_tempVersions?.Clear();
@@ -83,29 +80,40 @@ public async void LoadManifests(bool IsRefresh = false)
8380
tgCancelDownload.Visibility = Visibility.Collapsed;
8481

8582
MainWindow.Instance.CommandButtonsVisibility(Visibility.Collapsed);
86-
87-
if (Helper.IsConnectedToInternet())
83+
bool _isConnected = Helper.IsConnectedToInternet();
84+
if ((_isConnected && !Directory.Exists(Consts.ManifestPath)) || (_isConnected && IsRefresh is true))
8885
{
89-
if (!Directory.Exists(Consts.ManifestPath) || IsRefresh is true)
86+
if (IsRefresh)
9087
{
91-
if (IsRefresh)
92-
{
93-
txtStatus.Text = "Refreshing Packages...";
94-
}
95-
var manifestUrl = Consts.WingetPkgsRepository;
88+
txtStatus.Text = "Refreshing Packages...";
89+
}
90+
var manifestUrl = Consts.WingetPkgsRepository;
9691

97-
WebClient client = new WebClient();
92+
WebClient client = new WebClient();
9893

99-
client.DownloadFileCompleted += Client_DownloadFileCompleted;
100-
client.DownloadProgressChanged += Client_DownloadProgressChanged;
101-
await client.DownloadFileTaskAsync(new Uri(manifestUrl), Consts.RootPath + @"\winget-pkgs-master.zip");
94+
client.DownloadFileCompleted += Client_DownloadFileCompleted;
95+
client.DownloadProgressChanged += Client_DownloadProgressChanged;
96+
await client.DownloadFileTaskAsync(new Uri(manifestUrl), Consts.RootPath + @"\winget-pkgs-master.zip");
97+
98+
}
99+
else if (Directory.Exists(Consts.ManifestPath))
100+
{
101+
if (!_isConnected && IsRefresh)
102+
{
103+
Growl.WarningGlobal("Unable to connect to the Internet, we Load local packages.");
102104
}
105+
LoadLocalManifests();
103106
}
104107
else
105108
{
106109
Growl.ErrorGlobal("Unable to connect to the Internet");
107110
}
111+
}
108112

113+
private async void LoadLocalManifests()
114+
{
115+
int _totalmanifestsCount = 0;
116+
int _currentManifestCount = 0;
109117
if (Directory.Exists(Consts.ManifestPath))
110118
{
111119
prgStatus.IsIndeterminate = false;
@@ -277,6 +285,7 @@ await Task.Run(()=> {
277285
}
278286
}
279287
});
288+
LoadLocalManifests();
280289
}
281290

282291
private async void tgCancelDownload_Checked(object sender, RoutedEventArgs e)

0 commit comments

Comments
 (0)