Skip to content

Commit

Permalink
Fix second test of LT-21702
Browse files Browse the repository at this point in the history
  • Loading branch information
jtmaxwell3 authored and jasonleenaylor committed Jul 10, 2024
1 parent 548fc4b commit a2f79d4
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions Src/xWorks/XhtmlDocView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ internal class XhtmlDocView : XWorksViewBase, IFindAndReplaceContext, IPostLayou
internal string m_configObjectName;
internal const string CurrentSelectedEntryClass = "currentSelectedEntry";
private const string FieldWorksPrintLimitEnv = "FIELDWORKS_PRINT_LIMIT";
private bool m_jumpToRecord = false; // Whether we got a JumpToRecord signal
private bool m_updateContentLater = false; // Whether we should postpone calling UpdateContent
private string m_loadedConfig = null;

private GeckoWebBrowser GeckoBrowser => (GeckoWebBrowser)m_mainView.NativeBrowser;

Expand Down Expand Up @@ -178,7 +179,8 @@ public bool OnJumpToRecord(object argument)
GiveSimpleWarning(xrc);
}
}
m_jumpToRecord = true;
// Wait until SetActiveSelectedEntryOnView to call UpdateContent.
m_updateContentLater = true;
return false;
}

Expand Down Expand Up @@ -1003,14 +1005,20 @@ public void OnPropertyChanged(string name)
case "ReversalIndexPublicationLayout":
var currentConfig = GetCurrentConfiguration(false);
if (name == "ReversalIndexPublicationLayout")
{
DictionaryConfigurationUtils.SetReversalIndexGuidBasedOnReversalIndexConfiguration(m_propertyTable, Cache);
// Wait until SetActiveSelectedEntryOnView to call UpdateContent.
m_updateContentLater = true;
}
var currentPublication = GetCurrentPublication();
var validPublication = GetValidPublicationForConfiguration(currentConfig) ?? xWorksStrings.AllEntriesPublication;
if (validPublication != currentPublication)
{
m_propertyTable.SetProperty("SelectedPublication", validPublication, false);
}
UpdateContent(currentConfig);
if (!m_updateContentLater)
// Do it now.
UpdateContent(currentConfig);
break;
case "ActiveClerkSelectedObject":
var browser = m_mainView.NativeBrowser as GeckoWebBrowser;
Expand Down Expand Up @@ -1085,15 +1093,14 @@ private void SetActiveSelectedEntryOnView(GeckoWebBrowser browser)
var newConfig = Path.Combine(DictionaryConfigurationListener.GetProjectConfigurationDirectory(m_propertyTable),
writingSystem.Id + DictionaryConfigurationModel.FileExtension);
m_propertyTable.SetProperty("ReversalIndexPublicationLayout", File.Exists(newConfig) ? newConfig : null, true);
} else if (currentPage == null && m_jumpToRecord)
} else if (m_updateContentLater)
{
// Force the content to be updated once (LT-21702).
// This isn't needed when ReversalIndexPublicationLayout is changed
// because it causes the content to be updated as a side effect.
UpdateContent(currentConfig);
m_updateContentLater = false;
}
// Clear m_jumpToRecord no matter what.
m_jumpToRecord = false;
}
var currentObjectGuid = Clerk.CurrentObject.Guid.ToString();
var currSelectedByGuid = browser.Document.GetHtmlElementById("g" + currentObjectGuid);
Expand Down Expand Up @@ -1212,6 +1219,10 @@ private void UpdateContent(string configurationFile, bool allOnOnePage = false)
}
else
{
// Don't load the configuration file twice.
if (configurationFile == m_loadedConfig)
return;
m_loadedConfig = configurationFile;
var xhtmlPath = SaveConfiguredXhtmlWithProgress(configurationFile, allOnOnePage);
if (xhtmlPath != null)
{
Expand Down

0 comments on commit a2f79d4

Please sign in to comment.