@@ -50,11 +50,11 @@ public Packages()
50
50
BindingOperations . EnableCollectionSynchronization ( DataList , Lock ) ;
51
51
BindingOperations . EnableCollectionSynchronization ( _temoList , Lock ) ;
52
52
BindingOperations . EnableCollectionSynchronization ( _tempVersions , Lock ) ;
53
- LoadManifests ( ) ;
54
- InitSettings ( ) ;
53
+ DownloadManifests ( ) ;
54
+ SetDataListGrouping ( ) ;
55
55
}
56
56
57
- private void InitSettings ( )
57
+ private void SetDataListGrouping ( )
58
58
{
59
59
dataGrid . RowDetailsVisibilityMode = Settings . ShowExtraDetails ;
60
60
@@ -69,11 +69,8 @@ private void InitSettings()
69
69
}
70
70
}
71
71
72
- public async void LoadManifests ( bool IsRefresh = false )
72
+ public async void DownloadManifests ( bool IsRefresh = false )
73
73
{
74
- int _totalmanifestsCount = 0 ;
75
- int _currentManifestCount = 0 ;
76
-
77
74
DataList ? . Clear ( ) ;
78
75
_temoList ? . Clear ( ) ;
79
76
_tempVersions ? . Clear ( ) ;
@@ -83,29 +80,40 @@ public async void LoadManifests(bool IsRefresh = false)
83
80
tgCancelDownload . Visibility = Visibility . Collapsed ;
84
81
85
82
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 ) )
88
85
{
89
- if ( ! Directory . Exists ( Consts . ManifestPath ) || IsRefresh is true )
86
+ if ( IsRefresh )
90
87
{
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 ;
96
91
97
- WebClient client = new WebClient ( ) ;
92
+ WebClient client = new WebClient ( ) ;
98
93
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." ) ;
102
104
}
105
+ LoadLocalManifests ( ) ;
103
106
}
104
107
else
105
108
{
106
109
Growl . ErrorGlobal ( "Unable to connect to the Internet" ) ;
107
110
}
111
+ }
108
112
113
+ private async void LoadLocalManifests ( )
114
+ {
115
+ int _totalmanifestsCount = 0 ;
116
+ int _currentManifestCount = 0 ;
109
117
if ( Directory . Exists ( Consts . ManifestPath ) )
110
118
{
111
119
prgStatus . IsIndeterminate = false ;
@@ -277,6 +285,7 @@ await Task.Run(()=> {
277
285
}
278
286
}
279
287
} ) ;
288
+ LoadLocalManifests ( ) ;
280
289
}
281
290
282
291
private async void tgCancelDownload_Checked ( object sender , RoutedEventArgs e )
0 commit comments