summaryrefslogtreecommitdiff
path: root/ext/js/display/display.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2022-08-20 11:31:50 -0400
committerGitHub <noreply@github.com>2022-08-20 11:31:50 -0400
commit5c267f4bb772bb6c67576f2b40234a356c040550 (patch)
tree47ed99f483dcbb558f1976551cb511775a241001 /ext/js/display/display.js
parent9436928e3d89110d042e39067f5591c48e8500ea (diff)
Profile index fixes (#2207)
* Update settings controller to consistently initialize * Allow profile index to be reset if an error occurs * Update message handler to be async * Fix error when deleting the current profile
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}) {