Add reload mechanism for modified loaded parents

- Issue MatterHackers/MCCentral#4249
Parent library container shows stale view when popped
This commit is contained in:
John Lewin 2018-10-05 14:47:43 -07:00
parent 95ed6cc64f
commit 39241d4f09

View file

@ -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();
}));
}