Skip to content

Commit

Permalink
Fix NRE on Check Update when no new version is available
Browse files Browse the repository at this point in the history
  • Loading branch information
bagusnl committed Nov 3, 2024
1 parent e2ca70f commit b4b8832
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions CollapseLauncher/XAMLs/MainApp/Pages/SettingsPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
using CollapseLauncher.Helper.Image;
using CollapseLauncher.Helper.Metadata;
using CollapseLauncher.Helper.Update;
using CollapseLauncher.Interfaces;
using CollapseLauncher.Pages.OOBE;
using CollapseLauncher.Statics;
using CommunityToolkit.WinUI;
Expand Down Expand Up @@ -305,14 +304,15 @@ private async void CheckUpdate(object sender, RoutedEventArgs e)

LauncherUpdateInvoker.UpdateEvent += LauncherUpdateInvoker_UpdateEvent;
bool isUpdateAvailable = await LauncherUpdateHelper.IsUpdateAvailable(true);
if (LauncherUpdateHelper.AppUpdateVersionProp.Version != null)
LauncherUpdateWatcher.GetStatus(new LauncherUpdateProperty
{
LauncherUpdateWatcher.GetStatus(new LauncherUpdateProperty
{
IsUpdateAvailable = isUpdateAvailable,
NewVersionName = LauncherUpdateHelper.AppUpdateVersionProp.Version.Value
});
}
IsUpdateAvailable = isUpdateAvailable,
// ReSharper disable PossibleInvalidOperationException
NewVersionName = (GameVersion)(isUpdateAvailable
? LauncherUpdateHelper.AppUpdateVersionProp.Version.Value
: LauncherUpdateHelper.LauncherCurrentVersion)
// ReSharper restore PossibleInvalidOperationException
});
}
catch (Exception ex)
{
Expand Down Expand Up @@ -425,14 +425,14 @@ private async void SelectBackgroundImg(object sender, RoutedEventArgs e)
BGPathDisplay.Text = file;

GamePresetProperty currentGameProperty = GamePropertyVault.GetCurrentGameProperty();
bool isUseRegionCustomBG = ((IGameSettingsUniversal)currentGameProperty?._GameSettings)?.SettingsCollapseMisc?.UseCustomRegionBG ?? false;
bool isUseRegionCustomBG = currentGameProperty?._GameSettings?.SettingsCollapseMisc?.UseCustomRegionBG ?? false;
if (!isUseRegionCustomBG)
{
BackgroundImgChanger.ChangeBackground(LauncherMetadataHelper.CurrentMetadataConfig.GameLauncherApi.GameBackgroundImgLocal, null, true, true, true);
}
else if (!string.IsNullOrEmpty(((IGameSettingsUniversal)currentGameProperty._GameSettings)?.SettingsCollapseMisc?.CustomRegionBGPath))
else if (!string.IsNullOrEmpty(currentGameProperty._GameSettings?.SettingsCollapseMisc?.CustomRegionBGPath))
{
currentMediaType = BackgroundMediaUtility.GetMediaType(((IGameSettingsUniversal)currentGameProperty._GameSettings)?.SettingsCollapseMisc?.CustomRegionBGPath);
_ = BackgroundMediaUtility.GetMediaType(currentGameProperty._GameSettings?.SettingsCollapseMisc?.CustomRegionBGPath);
}
}
}
Expand All @@ -457,7 +457,7 @@ private bool IsBGCustom
{
bool isEnabled = GetAppConfigValue("UseCustomBG").ToBool();
string BGPath = GetAppConfigValue("CustomBGPath").ToString();
LogWriteLine("Read " + isEnabled + " BG Path: " + BGPath + " from config", LogType.Debug, false);
LogWriteLine("Read " + isEnabled + " BG Path: " + BGPath + " from config", LogType.Scheme, true);
if (!string.IsNullOrEmpty(BGPath))
BGPathDisplay.Text = BGPath;
else
Expand All @@ -481,7 +481,7 @@ private bool IsBGCustom
{
SetAndSaveConfigValue("UseCustomBG", value);
GamePresetProperty currentGameProperty = GamePropertyVault.GetCurrentGameProperty();
bool isUseRegionCustomBG = ((IGameSettingsUniversal)currentGameProperty?._GameSettings)?.SettingsCollapseMisc?.UseCustomRegionBG ?? false;
bool isUseRegionCustomBG = currentGameProperty?._GameSettings?.SettingsCollapseMisc?.UseCustomRegionBG ?? false;
if (!value)
{
LauncherMetadataHelper.CurrentMetadataConfig.GameLauncherApi.GameBackgroundImgLocal = GetAppConfigValue("CurrentBackground").ToString();
Expand All @@ -491,7 +491,7 @@ private bool IsBGCustom
}
else if (isUseRegionCustomBG)
{
string currentRegionCustomBg = ((IGameSettingsUniversal)currentGameProperty._GameSettings).SettingsCollapseMisc.CustomRegionBGPath;
string currentRegionCustomBg = currentGameProperty._GameSettings.SettingsCollapseMisc.CustomRegionBGPath;
LauncherMetadataHelper.CurrentMetadataConfig.GameLauncherApi.GameBackgroundImgLocal = currentRegionCustomBg;
m_mainPage?.ChangeBackgroundImageAsRegionAsync();

Expand Down

0 comments on commit b4b8832

Please sign in to comment.