update customization logic
authorYurii Zinchuk/Tizen Services & IoT (PLT) /SRPOL/Engineer/Samsung Electronics <y.zinchuk@samsung.com>
Wed, 10 Jan 2024 11:37:33 +0000 (12:37 +0100)
committerYurii Zinchuk/Tizen Services & IoT (PLT) /SRPOL/Engineer/Samsung Electronics <y.zinchuk@samsung.com>
Tue, 16 Jan 2024 13:06:38 +0000 (14:06 +0100)
SettingView/SettingView.cs

index e5e195982e97825dfd831e0d9274a34f50132f91..2eca6dc188a793fbb49ceb5096fba8181f7ec5ab 100644 (file)
@@ -184,15 +184,30 @@ namespace SettingView
 
                 var customizationMainMenusStr = customizationMainMenus.Where(i => i.IsVisible).Select(x => new string(x.Path));
                 var cacheMainMenuStr = MainMenuInfo.CacheMenu.Select(x => new string(x.Path));
+                var notCachedGadgets = customizationMainMenusStr.Except(cacheMainMenuStr);
+                var removedGedgets = cacheMainMenuStr.Except(customizationMainMenusStr);
 
                 if (!customizationMainMenusStr.SequenceEqual(cacheMainMenuStr))
                 {
-                    Logger.Verbose($"customization has changed. Reload main view.");
-                    if (page != null)
+                    var newMainMenus = new List<SettingGadgetInfo>();
+
+                    if (notCachedGadgets.Count() > 0)
+                    {
+                        foreach (var gadgetInfo in customizationMainMenus.Where(a => notCachedGadgets.Any(e => e.Equals(a.Path))))
+                        {
+                            if (MainMenuInfo.Create(gadgetInfo) is MainMenuInfo menu)
+                            {
+                                newMainMenus.Add(gadgetInfo);
+                            }
+                        }
+                    }
+
+                    if (removedGedgets.Count() > 0 || newMainMenus.Count() > 0)
                     {
+                        Logger.Verbose($"customization has changed. Reload main view.");
                         await Post(() =>
                         {
-                            CreateContent();
+                            CreateContent(true);
                             return true;
                         });
                     }