@@ -63,17 +63,28 @@ protected override async Task<int> InitAsync(CancellationToken token)
6363 "information" ,
6464 "en.json" ) ;
6565
66- // Fetch social and news independently so one failing doesn't block the other.
66+ // Fetch social and news in parallel so one failing doesn't delay the other.
67+ await Task . WhenAll (
68+ FetchSocialAsync ( requestSocialUrl , token ) ,
69+ FetchNewsAsync ( requestNewsUrl , token ) ) ;
70+
71+ return 0 ;
72+ }
73+
74+ private async Task FetchSocialAsync ( string url , CancellationToken token )
75+ {
6776 try
6877 {
78+ SharedStatic . InstanceLogger . LogDebug (
79+ "[WuwaGlobalLauncherApiNews::FetchSocialAsync] Requesting: {Url}" , url ) ;
6980#if ! USELIGHTWEIGHTJSONPARSER
7081 ApiResponseSocialMedia = await ApiResponseHttpClient
7182 . GetApiResponseFromJsonAsync (
72- requestSocialUrl ,
83+ url ,
7384 WuwaApiResponseContext . Default . WuwaApiResponseSocial ,
7485 token ) ;
7586#else
76- await using var socialStream = await ApiResponseHttpClient . GetStreamAsync ( requestSocialUrl , token ) ;
87+ await using var socialStream = await ApiResponseHttpClient . GetStreamAsync ( url , token ) ;
7788 ApiResponseSocialMedia = await System . Text . Json . JsonSerializer . DeserializeAsync (
7889 socialStream ,
7990 WuwaApiResponseContext . Default . WuwaApiResponseSocial ,
@@ -84,20 +95,25 @@ protected override async Task<int> InitAsync(CancellationToken token)
8495 catch ( Exception ex )
8596 {
8697 SharedStatic . InstanceLogger . LogWarning (
87- "[WuwaGlobalLauncherApiNews::InitAsync ] Failed to load social media entries: {Error}" ,
88- ex . Message ) ;
98+ "[WuwaGlobalLauncherApiNews::FetchSocialAsync ] Failed to load social media entries from {Url} : {Error}" ,
99+ url , ex . Message ) ;
89100 }
101+ }
90102
103+ private async Task FetchNewsAsync ( string url , CancellationToken token )
104+ {
91105 try
92106 {
107+ SharedStatic . InstanceLogger . LogDebug (
108+ "[WuwaGlobalLauncherApiNews::FetchNewsAsync] Requesting: {Url}" , url ) ;
93109#if ! USELIGHTWEIGHTJSONPARSER
94110 ApiResponseNewsAndCarousel = await ApiResponseHttpClient
95111 . GetApiResponseFromJsonAsync (
96- requestNewsUrl ,
112+ url ,
97113 WuwaApiResponseContext . Default . WuwaApiResponseNews ,
98114 token ) ;
99115#else
100- await using var newsStream = await ApiResponseHttpClient . GetStreamAsync ( requestNewsUrl , token ) ;
116+ await using var newsStream = await ApiResponseHttpClient . GetStreamAsync ( url , token ) ;
101117 ApiResponseNewsAndCarousel = await System . Text . Json . JsonSerializer . DeserializeAsync (
102118 newsStream ,
103119 WuwaApiResponseContext . Default . WuwaApiResponseNews ,
@@ -108,11 +124,9 @@ protected override async Task<int> InitAsync(CancellationToken token)
108124 catch ( Exception ex )
109125 {
110126 SharedStatic . InstanceLogger . LogWarning (
111- "[WuwaGlobalLauncherApiNews::InitAsync ] Failed to load news/carousel entries: {Error}" ,
112- ex . Message ) ;
127+ "[WuwaGlobalLauncherApiNews::FetchNewsAsync ] Failed to load news/carousel entries from {Url} : {Error}" ,
128+ url , ex . Message ) ;
113129 }
114-
115- return 0 ;
116130 }
117131
118132 public override void GetNewsEntries ( out nint handle , out int count , out bool isDisposable , out bool isAllocated )
0 commit comments