summaryrefslogtreecommitdiff
path: root/ext/bg/js/settings/dictionaries.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-07-03 11:56:26 -0400
committerGitHub <noreply@github.com>2020-07-03 11:56:26 -0400
commitc13160d784caf5ca2803081171d1c01eb91f49c6 (patch)
tree88526d4c338cea194cc3d5a998d6cab17d12e23d /ext/bg/js/settings/dictionaries.js
parent1d02013642df825f3539b03c325dc51d9fd00e83 (diff)
Page exit prevention refactor (#637)
* Add page exit prevention functionality to SettingsController * Update dictionary controller to use new page exit prevention system * Remove page-exit-prevention.js
Diffstat (limited to 'ext/bg/js/settings/dictionaries.js')
-rw-r--r--ext/bg/js/settings/dictionaries.js21
1 files changed, 13 insertions, 8 deletions
diff --git a/ext/bg/js/settings/dictionaries.js b/ext/bg/js/settings/dictionaries.js
index 94a71233..1e780909 100644
--- a/ext/bg/js/settings/dictionaries.js
+++ b/ext/bg/js/settings/dictionaries.js
@@ -16,7 +16,6 @@
*/
/* global
- * PageExitPrevention
* api
* utilBackgroundIsolate
*/
@@ -156,6 +155,11 @@ class SettingsDictionaryListUI extends EventDispatcher {
// Overwrite
}
+ preventPageExit() {
+ // Overwrite
+ return {end: () => {}};
+ }
+
onDictionaryConfirmDelete(e) {
e.preventDefault();
const n = document.querySelector('#dict-delete-modal');
@@ -286,10 +290,8 @@ class SettingsDictionaryEntryUI {
const progressBar = this.content.querySelector('.progress-bar');
this.isDeleting = true;
- const prevention = new PageExitPrevention();
+ const prevention = this.parent.preventPageExit();
try {
- prevention.start();
-
const onProgress = ({processed, count, storeCount, storesProcesed}) => {
let percent = 0.0;
if (count > 0 && storesProcesed > 0) {
@@ -409,6 +411,7 @@ class DictionaryController {
document.querySelector('#dict-extra-template')
);
this._dictionaryUI.save = () => this._settingsController.save();
+ this._dictionaryUI.preventPageExit = this._preventPageExit.bind(this);
this._dictionaryUI.on('databaseUpdated', this._onDatabaseUpdated.bind(this));
document.querySelector('#dict-purge-button').addEventListener('click', this._onPurgeButtonClick.bind(this), false);
@@ -610,10 +613,9 @@ class DictionaryController {
const dictProgress = document.querySelector('#dict-purge');
dictProgress.hidden = false;
- const prevention = new PageExitPrevention();
+ const prevention = this._preventPageExit();
try {
- prevention.start();
this._dictionaryErrorsShow(null);
this._dictionarySpinnerShow(true);
@@ -649,10 +651,9 @@ class DictionaryController {
const dictProgress = $('#dict-import-progress').show();
const dictImportInfo = document.querySelector('#dict-import-info');
- const prevention = new PageExitPrevention();
+ const prevention = this._preventPageExit();
try {
- prevention.start();
this._dictionaryErrorsShow(null);
this._dictionarySpinnerShow(true);
@@ -718,4 +719,8 @@ class DictionaryController {
optionsFull.global.database.prefixWildcardsSupported = !!e.target.checked;
await this._settingsController.save();
}
+
+ _preventPageExit() {
+ return this.settingsController.preventPageExit();
+ }
}