Browse Source

Fixed tests

CPKreuz 4 years ago
parent
commit
6de5361da6

+ 12 - 3
PixiEditor/Models/UserPreferences/PreferencesSettings.cs

@@ -57,7 +57,10 @@ namespace PixiEditor.Models.UserPreferences
 
             if (Callbacks.ContainsKey(name))
             {
-                Callbacks[name].Invoke(value);
+                foreach (var action in Callbacks[name])
+                {
+                    action.Invoke(value);
+                }
             }
 
             Save();
@@ -75,11 +78,17 @@ namespace PixiEditor.Models.UserPreferences
 
 #nullable enable
 
-        public static Dictionary<string, Action<object>> Callbacks { get; set; } = new Dictionary<string, Action<object>>();
+        public static Dictionary<string, List<Action<object>>> Callbacks { get; set; } = new Dictionary<string, List<Action<object>>>();
 
         public static void AddCallback(string setting, Action<object> action)
         {
-            Callbacks.Add(setting, action);
+            if (Callbacks.ContainsKey(setting))
+            {
+                Callbacks[setting].Add(action);
+                return;
+            }
+
+            Callbacks.Add(setting, new List<Action<object>>() { action });
         }
 
         public static T? GetPreference<T>(string name)

+ 5 - 0
PixiEditor/ViewModels/SubViewModels/Main/DiscordViewModel.cs

@@ -60,6 +60,11 @@ namespace PixiEditor.ViewModels.SubViewModels.Main
 
         public void UpdatePresence(Document document)
         {
+            if (client == null)
+            {
+                return;
+            }
+
             RichPresence richPresence = new RichPresence
             {
                 Assets = new Assets