33using Microsoft . UI . Xaml . Controls ;
44using Microsoft . Windows . AppNotifications ;
55using Microsoft . Windows . AppNotifications . Builder ;
6+ using Newtonsoft . Json . Linq ;
7+ using System . Linq ;
8+ using System . Net . Http ;
9+ using System . Net . Http . Headers ;
610using Windows . ApplicationModel ;
711using Windows . ApplicationModel . DataTransfer ;
812
@@ -25,8 +29,15 @@ private async void CheckAppVersion(object sender, RoutedEventArgs e)
2529 {
2630 if ( App . LatestVersion == null )
2731 {
28- Octokit . GitHubClient client = new ( new Octokit . ProductHeaderValue ( "Edge" ) ) ;
29- App . LatestVersion = ( await client . Repository . GetAllTags ( "wtcpython" , "WinUIEdge" ) ) [ 0 ] . Name [ 1 ..] ;
32+ HttpClient httpClient = new ( ) ;
33+ httpClient . DefaultRequestHeaders . UserAgent . TryParseAdd ( "wtcpython/WinUIEdge 1.0" ) ;
34+ httpClient . DefaultRequestHeaders . Accept . Add ( new MediaTypeWithQualityHeaderValue ( "application/vnd.github.v3+json" ) ) ;
35+
36+ HttpResponseMessage response = await httpClient . GetAsync ( "https://api.github.com/repos/wtcpython/WinUIEdge/tags" ) ;
37+
38+ string content = await response . Content . ReadAsStringAsync ( ) ;
39+
40+ App . LatestVersion = JArray . Parse ( content ) . First ( ) [ "name" ] . ToString ( ) [ 1 ..] ;
3041 }
3142 if ( App . LatestVersion . CompareTo ( appVersion ) > 0 )
3243 {
@@ -41,7 +52,7 @@ private async void CheckAppVersion(object sender, RoutedEventArgs e)
4152 notificationManager . Show ( builder . BuildNotification ( ) ) ;
4253 }
4354 }
44- catch ( Octokit . RateLimitExceededException ) { }
55+ catch ( HttpRequestException ) { }
4556 }
4657
4758 private void CopyText ( string text )
0 commit comments