summaryrefslogtreecommitdiff
path: root/ext/js/display/display.js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/js/display/display.js')
-rw-r--r--ext/js/display/display.js18
1 files changed, 11 insertions, 7 deletions
diff --git a/ext/js/display/display.js b/ext/js/display/display.js
index 923c9dd2..8905d304 100644
--- a/ext/js/display/display.js
+++ b/ext/js/display/display.js
@@ -178,7 +178,7 @@ class Display extends EventDispatcher {
['previousEntryDifferentDictionary', () => { this._focusEntryWithDifferentDictionary(-1, true); }]
]);
this.registerDirectMessageHandlers([
- ['Display.setOptionsContext', {async: false, handler: this._onMessageSetOptionsContext.bind(this)}],
+ ['Display.setOptionsContext', {async: true, handler: this._onMessageSetOptionsContext.bind(this)}],
['Display.setContent', {async: false, handler: this._onMessageSetContent.bind(this)}],
['Display.setCustomCss', {async: false, handler: this._onMessageSetCustomCss.bind(this)}],
['Display.setContentScale', {async: false, handler: this._onMessageSetContentScale.bind(this)}],
@@ -459,21 +459,25 @@ class Display extends EventDispatcher {
this._documentFocusController.blurElement(element);
}
- searchLast() {
+ searchLast(updateOptionsContext) {
const type = this._contentType;
if (type === 'clear') { return; }
const query = this._query;
+ const hasState = this._historyHasState();
const state = (
- this._historyHasState() ?
+ hasState ?
clone(this._history.state) :
{
focusEntry: 0,
- optionsContext: this._optionsContext,
+ optionsContext: null,
url: window.location.href,
sentence: {text: query, offset: 0},
documentTitle: document.title
}
);
+ if (!hasState || updateOptionsContext) {
+ state.optionsContext = clone(this._optionsContext);
+ }
const details = {
focus: false,
historyMode: 'clear',
@@ -551,9 +555,9 @@ class Display extends EventDispatcher {
invokeMessageHandler(messageHandler, params, callback);
}
- _onMessageSetOptionsContext({optionsContext}) {
- this.setOptionsContext(optionsContext);
- this.searchLast();
+ async _onMessageSetOptionsContext({optionsContext}) {
+ await this.setOptionsContext(optionsContext);
+ this.searchLast(true);
}
_onMessageSetContent({details}) {