From 39241d4f09d57d315cfe05ab201b501d9805e330 Mon Sep 17 00:00:00 2001 From: John Lewin Date: Fri, 5 Oct 2018 14:47:43 -0700 Subject: [PATCH] Add reload mechanism for modified loaded parents - Issue MatterHackers/MCCentral#4249 Parent library container shows stale view when popped --- MatterControlLib/Library/Widgets/PrintLibraryWidget.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/MatterControlLib/Library/Widgets/PrintLibraryWidget.cs b/MatterControlLib/Library/Widgets/PrintLibraryWidget.cs index d143146e4..fa39227f5 100644 --- a/MatterControlLib/Library/Widgets/PrintLibraryWidget.cs +++ b/MatterControlLib/Library/Widgets/PrintLibraryWidget.cs @@ -31,6 +31,7 @@ using System; using System.Collections.Generic; using System.IO; using System.Linq; +using System.Threading.Tasks; #if !__ANDROID__ using Markdig.Agg; @@ -704,6 +705,15 @@ namespace MatterHackers.MatterControl.PrintLibrary DialogWindow.Show(new MoveItemPage((newName, destinationContainer) => { destinationContainer.Move(partItems, sourceContainer); + + // Discover if item was moved to an already loaded and now stale view on an ancestor and force reload + var openParent = ApplicationController.Instance.Library.ActiveContainer.Ancestors().FirstOrDefault(c => c.ID == destinationContainer.ID); + if (openParent != null) + { + // TODO: Consider changing this brute force approach to instead mark as dirty and allow Activate base method to reload if dirty + Task.Run(() => openParent.Load()); + } + libraryView.SelectedItems.Clear(); })); }