From b253cdc92e38e960a6256f8aad730624c37d2a1b Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Sun, 2 Aug 2020 21:51:51 -0400 Subject: Fix extension unload cases (#712) * Add _invokeSafe function to silently ignore extension unload errors * Remove "Api" from function names * Add invokeSafe to Popup * Don't redundantly set content type to 'unloaded' --- ext/mixed/js/display.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'ext/mixed/js') diff --git a/ext/mixed/js/display.js b/ext/mixed/js/display.js index d1f92722..93272666 100644 --- a/ext/mixed/js/display.js +++ b/ext/mixed/js/display.js @@ -69,6 +69,7 @@ class Display extends EventDispatcher { this._historyChangeIgnore = false; this._historyHasChanged = false; this._navigationHeader = document.querySelector('#navigation-header'); + this._contentType = 'clear'; this._defaultTitle = 'Yomichan Search'; this._defaultTitleMaxLength = 1000; this._fullQuery = ''; @@ -393,6 +394,7 @@ class Display extends EventDispatcher { let asigned = false; const eventArgs = {type, urlSearchParams, token}; this._historyHasChanged = true; + this._contentType = type; this._mediaLoader.unloadAll(); switch (type) { case 'terms': @@ -416,8 +418,10 @@ class Display extends EventDispatcher { const stale = (this._setContentToken !== token); if (!stale) { if (!asigned) { + type = 'clear'; + this._contentType = type; const {content} = this._history; - eventArgs.type = 'clear'; + eventArgs.type = type; eventArgs.content = content; this.trigger('contentUpdating', eventArgs); this._clearContent(); @@ -451,10 +455,12 @@ class Display extends EventDispatcher { } _onExtensionUnloaded() { + const type = 'unloaded'; + if (this._contentType === type) { return; } const details = { focus: false, history: false, - params: {type: 'unloaded'}, + params: {type}, state: {}, content: {} }; -- cgit v1.2.3