Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Src/Common/FwUtils/EventConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public static class EventConstants
public const string PrepareToRefresh = "PrepareToRefresh";
public const string RecordNavigation = "RecordNavigation";
public const string RefreshCurrentList = "RefreshCurrentList";
public const string RefreshCurrentView = "RefreshCurrentView";
public const string RefreshInterlin = "RefreshInterlin";
public const string RefreshPopupWindowFonts = "RefreshPopupWindowFonts";
public const string ReloadAreaTools = "ReloadAreaTools";
Expand Down
9 changes: 8 additions & 1 deletion Src/LexText/LexTextControls/EntryDlgListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,15 @@ private void DialogInsertItemInVector(object obj)
bool newby;
dlg.GetDialogInfo(out entry, out newby);
// No need for a PropChanged here because InsertEntryDlg takes care of that. (LT-3608)
// Two-stage refresh: if the active content control can satisfy the request by
// regenerating its own content (the XHTML document views), skip the full refresh.
var refreshRequest = new ReturnObject(null);
Publisher.Publish(new PublisherParameterObject(EventConstants.RefreshCurrentView, refreshRequest, m_propertyTable.GetWindow()));
if (!refreshRequest.ReturnValue)
{
Publisher.Publish(new PublisherParameterObject(EventConstants.MasterRefresh, null, m_propertyTable.GetWindow()));
}
#pragma warning disable 618 // suppress obsolete warning
m_mediator.SendMessage("MasterRefresh", null);
m_mediator.SendMessage("JumpToRecord", entry.Hvo);
#pragma warning restore 618
}
Expand Down
11 changes: 8 additions & 3 deletions Src/xWorks/RecordClerk.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1547,9 +1547,14 @@ private void DeleteRecord(object commandObject)
}
}
}
#pragma warning disable 618 // suppress obsolete warning
m_mediator.SendMessage("MasterRefresh", null);
#pragma warning restore 618
// Two-stage refresh: if the active content control can satisfy the request by
// regenerating its own content (the XHTML document views), skip the full refresh.
var refreshRequest = new ReturnObject(null);
Publisher.Publish(new PublisherParameterObject(EventConstants.RefreshCurrentView, refreshRequest, m_propertyTable.GetWindow()));
if (!refreshRequest.ReturnValue)
{
Publisher.Publish(new PublisherParameterObject(EventConstants.MasterRefresh, null, m_propertyTable.GetWindow()));
}
}
}
}
Expand Down
23 changes: 23 additions & 0 deletions Src/xWorks/XhtmlDocView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public override void Init(Mediator mediator, PropertyTable propertyTable, XmlNod
}
}
Subscriber.Subscribe(EventConstants.DictionaryConfigured, RefreshAllContent, m_propertyTable.GetWindow());
Subscriber.Subscribe(EventConstants.RefreshCurrentView, RefreshCurrentView, m_propertyTable.GetWindow());
}

protected override void Dispose(bool disposing)
Expand All @@ -93,6 +94,7 @@ protected override void Dispose(bool disposing)
if (disposing)
{
Subscriber.Unsubscribe(EventConstants.DictionaryConfigured, RefreshAllContent);
Subscriber.Unsubscribe(EventConstants.RefreshCurrentView, RefreshCurrentView);
}
base.Dispose(disposing);
}
Expand Down Expand Up @@ -1323,6 +1325,27 @@ public void OnMasterRefresh(object sender)
RefreshAllContent(null);
}

/// <summary>
/// First stage of a sender's two-stage refresh request: while this view is the active
/// content control it claims the request and satisfies it by regenerating its own
/// content, so the sender skips the full master refresh.
/// </summary>
private void RefreshCurrentView(object obj)
{
if (!(obj is ReturnObject retObj))
{
Debug.Assert(false, "Received unexpected object type.");
return;
}
// Return if already handled by another Subscriber.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would there ever be two current views that need to handle this (e.g. multiple panes or windows)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question — no, by design, on both counts:

Multiple windows: both ends are window-scoped (m_propertyTable.GetWindow()), so a publish from window A's clerk only reaches window A's subscribers. A second window showing the Dictionary view never sees the request (matching the old per-window Mediator behavior).

Multiple panes in one window: XhtmlDocView only exists as the main content control of the three document tools (Dictionary, Reversal Indexes, Classified Dictionary), and a window has exactly one main content control at a time (this is similar to what the Mediator relied on) — the view is disposed (and unsubscribed) on tool switch. The one view that can coexist alongside another content control, XhtmlRecordDocView (the Lexicon Edit preview pane), deliberately doesn't subscribe: in Lexicon Edit these commands should do the full refresh, and the preview updates via PropChanged. So at most one subscriber can receive any given request today.

if (retObj.ReturnValue)
{
return;
}
RefreshAllContent(null);
retObj.ReturnValue = true;
}

/// <summary>
/// Regenerate this view's XHTML content, ensuring the selected publication is valid for
/// the current configuration. Subscribed to the Pub/Sub DictionaryConfigured event.
Expand Down
Loading