From 42e6de359e3b292fa85e0f2f6dfe912f06f64891 Mon Sep 17 00:00:00 2001 From: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com> Date: Fri, 19 Jul 2024 02:00:47 +0300 Subject: [PATCH] Invert `WatchProperty(...)` methods' `watchInitialValue` --- DiscordChatExporter.Gui/App.axaml.cs | 3 +-- .../Extensions/NotifyPropertyChangedExtensions.cs | 10 +++------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/DiscordChatExporter.Gui/App.axaml.cs b/DiscordChatExporter.Gui/App.axaml.cs index b933efb..c9a5d91 100644 --- a/DiscordChatExporter.Gui/App.axaml.cs +++ b/DiscordChatExporter.Gui/App.axaml.cs @@ -65,8 +65,7 @@ public class App : Application, IDisposable }; InitializeTheme(); - }, - false + } ) ); } diff --git a/DiscordChatExporter.Gui/Utils/Extensions/NotifyPropertyChangedExtensions.cs b/DiscordChatExporter.Gui/Utils/Extensions/NotifyPropertyChangedExtensions.cs index 2f9744f..511adde 100644 --- a/DiscordChatExporter.Gui/Utils/Extensions/NotifyPropertyChangedExtensions.cs +++ b/DiscordChatExporter.Gui/Utils/Extensions/NotifyPropertyChangedExtensions.cs @@ -11,15 +11,11 @@ internal static class NotifyPropertyChangedExtensions this TOwner owner, Expression> propertyExpression, Action callback, - bool watchInitialValue = true + bool watchInitialValue = false ) where TOwner : INotifyPropertyChanged { - var memberExpression = - propertyExpression.Body as MemberExpression - // Property value might be boxed inside a conversion expression, if the types don't match - ?? (propertyExpression.Body as UnaryExpression)?.Operand as MemberExpression; - + var memberExpression = propertyExpression.Body as MemberExpression; if (memberExpression?.Member is not PropertyInfo property) throw new ArgumentException("Provided expression must reference a property."); @@ -45,7 +41,7 @@ internal static class NotifyPropertyChangedExtensions public static IDisposable WatchAllProperties( this TOwner owner, Action callback, - bool watchInitialValues = true + bool watchInitialValues = false ) where TOwner : INotifyPropertyChanged {