diff options
author | Wojtek Kosior <koszko@koszko.org> | 2022-03-04 15:56:50 +0100 |
---|---|---|
committer | Wojtek Kosior <koszko@koszko.org> | 2022-03-04 16:36:44 +0100 |
commit | 587c1a88475c162b820d94c37e2cd18eb4422276 (patch) | |
tree | 96b30c12159f63b30c621e227df634056424f92f /html/settings.js | |
parent | 652e4476fdc2c7177145c0d993159f84a5f64c55 (diff) | |
download | browser-extension-587c1a88475c162b820d94c37e2cd18eb4422276.tar.gz browser-extension-587c1a88475c162b820d94c37e2cd18eb4422276.zip |
display an informative message in settings page if IndexedDB cannot be accessed
Diffstat (limited to 'html/settings.js')
-rw-r--r-- | html/settings.js | 50 |
1 files changed, 45 insertions, 5 deletions
diff --git a/html/settings.js b/html/settings.js index 36eeb47..686cc11 100644 --- a/html/settings.js +++ b/html/settings.js @@ -41,8 +41,13 @@ * proprietary program, I am not going to enforce this in court. */ +#IMPORT common/indexeddb.js AS haketilodb #IMPORT html/dialog.js +#IF MOZILLA +#FROM common/browser.js IMPORT browser +#ENDIF + #FROM html/DOM_helpers.js IMPORT by_id #FROM html/text_entry_list.js IMPORT blocking_allowing_lists, repo_list #FROM html/item_list.js IMPORT mapping_list, resource_list @@ -118,8 +123,43 @@ async function set_up_repos_tab() { containers[0].append((await repo_list(dialog_ctx)).main_div); } -set_up_blocking_tab(); -set_up_mappings_tab(); -set_up_resources_tab(); -set_up_new_payload_tab(); -set_up_repos_tab(); +function set_up_settings_view() { + by_id("loader").remove(); + by_id("main_view").classList.remove("hide"); + + set_up_blocking_tab(); + set_up_mappings_tab(); + set_up_resources_tab(); + set_up_new_payload_tab(); + set_up_repos_tab(); +} + +#IF MOZILLA +async function show_indexeddb_error() { + const this_tab = await browser.tabs.getCurrent(); + if (this_tab.incognito) + by_id("indexeddb_private_mode_explanation").classList.remove("hide"); +#ELSE +function show_indexeddb_error() { +#ENDIF + by_id("loader").remove(); + by_id("indexeddb_error").classList.remove("hide"); +} + +async function init_settings_page() { + try { + await haketilodb.get(); + } catch(e) { + console.error(e); + show_indexeddb_error(); + return; + } + + set_up_settings_view(); +} + +#IF UNIT_TEST +window.init_settings_page = init_settings_page; +#ELSE +init_settings_page(); +#ENDIF |