Just null check the styles

This commit is contained in:
Infi
2024-04-12 22:11:17 +02:00
parent 4751e3c8f7
commit c66d97829c
12 changed files with 60 additions and 60 deletions
+4 -24
View File
@@ -101,34 +101,14 @@ public sealed class ChatLogWindow : Window, IUiComponent {
public override void PreDraw()
{
if (Plugin.Config.OverrideStyle && Plugin.Config.ChosenStyle != "")
{
var styles = StyleModel.GetConfiguredStyles();
try
{
styles?.First(style => style.Name.Equals(Plugin.Config.ChosenStyle)).Push();
}
catch (InvalidOperationException e)
{
// Swallow the error - User does not have a valid style set
}
}
if (Plugin.Config is { OverrideStyle: true, ChosenStyle: not null })
StyleModel.GetConfiguredStyles()?.FirstOrDefault(style => style.Name == Plugin.Config.ChosenStyle)?.Push();
}
public override void PostDraw()
{
if (Plugin.Config.OverrideStyle && Plugin.Config.ChosenStyle != "")
{
var styles = StyleModel.GetConfiguredStyles();
try
{
styles?.First(style => style.Name.Equals(Plugin.Config.ChosenStyle)).Pop();
}
catch (InvalidOperationException e)
{
// Swallow the error - User does not have a valid style set
}
}
if (Plugin.Config is { OverrideStyle: true, ChosenStyle: not null })
StyleModel.GetConfiguredStyles()?.FirstOrDefault(style => style.Name == Plugin.Config.ChosenStyle)?.Pop();
}
public void Dispose() {