summaryrefslogtreecommitdiff
path: root/ext/js/display
diff options
context:
space:
mode:
Diffstat (limited to 'ext/js/display')
-rw-r--r--ext/js/display/display.js18
-rw-r--r--ext/js/display/search-display-controller.js2
2 files changed, 12 insertions, 8 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}) {
diff --git a/ext/js/display/search-display-controller.js b/ext/js/display/search-display-controller.js
index cd35481d..6131e0db 100644
--- a/ext/js/display/search-display-controller.js
+++ b/ext/js/display/search-display-controller.js
@@ -135,7 +135,7 @@ class SearchDisplayController {
await this._display.updateOptions();
const query = this._queryInput.value;
if (query) {
- this._display.searchLast();
+ this._display.searchLast(false);
}
}