From 4dcd01283df115bfdf6f15f9007acfbfe05e8469 Mon Sep 17 00:00:00 2001 From: Kemal Setya Adhi Date: Sun, 24 Nov 2024 15:42:35 +0700 Subject: [PATCH] Fix NRE throw when featured icon doesn't exist --- CollapseLauncher/XAMLs/MainApp/Pages/HomePage.xaml.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/CollapseLauncher/XAMLs/MainApp/Pages/HomePage.xaml.cs b/CollapseLauncher/XAMLs/MainApp/Pages/HomePage.xaml.cs index 6ac5ca42c..13e5f8ef3 100644 --- a/CollapseLauncher/XAMLs/MainApp/Pages/HomePage.xaml.cs +++ b/CollapseLauncher/XAMLs/MainApp/Pages/HomePage.xaml.cs @@ -305,6 +305,10 @@ private async void TryLoadEventPanelImage() string featuredEventIconImg = LauncherMetadataHelper.CurrentMetadataConfig?.GameLauncherApi? .LauncherGameNews?.Content?.Background?.FeaturedEventIconBtnImg; + // If the region event panel property is null, then return + if (string.IsNullOrEmpty(featuredEventIconImg) + || string.IsNullOrEmpty(featuredEventArticleUrl)) return; + if (!_eventPanelProcessing.TryAdd(featuredEventArticleUrl, 0) || !_eventPanelProcessing.TryAdd(featuredEventIconImg, 0)) { @@ -313,9 +317,6 @@ private async void TryLoadEventPanelImage() return; } - // If the region event panel property is null, then return - if (string.IsNullOrEmpty(featuredEventIconImg)) return; - // Get the cached filename and path string cachedFileHash = BytesToCRC32Simple(featuredEventIconImg); string cachedFilePath = Path.Combine(AppGameImgCachedFolder, cachedFileHash);