Code cleanup + small regression

don't prompt if channel switching is auto
This commit is contained in:
1011025m 2023-11-01 00:06:18 +08:00
parent a3798f4a54
commit e62f8784a6

View File

@ -229,18 +229,15 @@ namespace Bloxstrap
} }
catch (HttpResponseException ex) catch (HttpResponseException ex)
{ {
if (ex.ResponseMessage.StatusCode != HttpStatusCode.NotFound && ex.ResponseMessage.StatusCode != HttpStatusCode.Unauthorized) // If channel does not exist
throw;
if (ex.ResponseMessage.StatusCode == HttpStatusCode.NotFound) if (ex.ResponseMessage.StatusCode == HttpStatusCode.NotFound)
App.Logger.WriteLine(LOG_IDENT, $"Reverting enrolled channel to {RobloxDeployment.DefaultChannel} because a WindowsPlayer build does not exist for {App.Settings.Prop.Channel}"); App.Logger.WriteLine(LOG_IDENT, $"Reverting enrolled channel to {RobloxDeployment.DefaultChannel} because a WindowsPlayer build does not exist for {App.Settings.Prop.Channel}");
// Janky fix for error 401 ~25/10/2023 // If channel is not available to the user (private/internal release channel)
if (ex.ResponseMessage.StatusCode == HttpStatusCode.Unauthorized) else if (ex.ResponseMessage.StatusCode == HttpStatusCode.Unauthorized)
{ {
App.Logger.WriteLine(LOG_IDENT, $"Channel {App.Settings.Prop.Channel} is unavailable to the user."); App.Logger.WriteLine(LOG_IDENT, $"Channel {App.Settings.Prop.Channel} is unavailable to the user.");
if (App.Settings.Prop.ChannelChangeMode == ChannelChangeMode.Automatic) // Only prompt if user has channel switching mode set to something other than Automatic.
Controls.ShowMessageBox($"Release channel {App.Settings.Prop.Channel} is not available to you. It has been reset to {RobloxDeployment.DefaultChannel}.", MessageBoxImage.Information); if (App.Settings.Prop.ChannelChangeMode != ChannelChangeMode.Automatic)
else
{ {
MessageBoxResult channelChangeResult = Controls.ShowMessageBox( MessageBoxResult channelChangeResult = Controls.ShowMessageBox(
$"Release channel {App.Settings.Prop.Channel} is not available to you. Would you like to reset to {RobloxDeployment.DefaultChannel}?", $"Release channel {App.Settings.Prop.Channel} is not available to you. Would you like to reset to {RobloxDeployment.DefaultChannel}?",
@ -256,6 +253,7 @@ namespace Bloxstrap
} }
App.Logger.WriteLine(LOG_IDENT, $"Resetting release channel to {RobloxDeployment.DefaultChannel} as {App.Settings.Prop.Channel} is unavailable to the user."); App.Logger.WriteLine(LOG_IDENT, $"Resetting release channel to {RobloxDeployment.DefaultChannel} as {App.Settings.Prop.Channel} is unavailable to the user.");
} }
else throw;
App.Settings.Prop.Channel = RobloxDeployment.DefaultChannel; App.Settings.Prop.Channel = RobloxDeployment.DefaultChannel;
clientVersion = await RobloxDeployment.GetInfo(App.Settings.Prop.Channel); clientVersion = await RobloxDeployment.GetInfo(App.Settings.Prop.Channel);