aboutsummaryrefslogtreecommitdiff
path: root/ext/js/pages/settings/permissions-toggle-controller.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2024-01-31 08:38:30 -0500
committerGitHub <noreply@github.com>2024-01-31 13:38:30 +0000
commit87ed7c8affd3ade9d3cd2d9ed1a61dd5f224e473 (patch)
treebe727294e31ef21e8a3f634734610e69e4a155ac /ext/js/pages/settings/permissions-toggle-controller.js
parent3e419aa562aab03ca20421aaf7e4d1a39194a5b4 (diff)
Module refactoring (#588)
* Convert PronunciationGenerator into static functions * Convert DictionaryDataUtil into static functions * Convert AnkiNoteDataCreator into static functions * Convert MediaUtil into static functions * Convert RegexUtil into static functions * Convert StringUtil into static functions * Convert ArrayBufferUtil into static functions * Convert AnkiUtil into static functions * Convert PermissionsUtil into static functions * Convert ProfileConditionsUtil into static functions
Diffstat (limited to 'ext/js/pages/settings/permissions-toggle-controller.js')
-rw-r--r--ext/js/pages/settings/permissions-toggle-controller.js13
1 files changed, 7 insertions, 6 deletions
diff --git a/ext/js/pages/settings/permissions-toggle-controller.js b/ext/js/pages/settings/permissions-toggle-controller.js
index c775aa12..25204dce 100644
--- a/ext/js/pages/settings/permissions-toggle-controller.js
+++ b/ext/js/pages/settings/permissions-toggle-controller.js
@@ -16,6 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
+import {getAllPermissions, hasPermissions, setPermissionsGranted} from '../../data/permissions-util.js';
import {ObjectPropertyAccessor} from '../../general/object-property-accessor.js';
export class PermissionsToggleController {
@@ -85,11 +86,11 @@ export class PermissionsToggleController {
toggle.checked = valuePre;
const permissions = this._getRequiredPermissions(toggle);
try {
- value = await this._settingsController.permissionsUtil.setPermissionsGranted({permissions}, value);
+ value = await setPermissionsGranted({permissions}, value);
} catch (error) {
value = valuePre;
try {
- value = await this._settingsController.permissionsUtil.hasPermissions({permissions});
+ value = await hasPermissions({permissions});
} catch (error2) {
// NOP
}
@@ -111,13 +112,13 @@ export class PermissionsToggleController {
const permissionsSet = new Set(typeof permissions2 !== 'undefined' ? permissions2 : []);
for (const toggle of /** @type {NodeListOf<HTMLInputElement>} */ (this._toggles)) {
const {permissionsSetting} = toggle.dataset;
- const hasPermissions = this._hasAll(permissionsSet, this._getRequiredPermissions(toggle));
+ const hasPermissions2 = this._hasAll(permissionsSet, this._getRequiredPermissions(toggle));
if (typeof permissionsSetting === 'string') {
- const valid = !toggle.checked || hasPermissions;
+ const valid = !toggle.checked || hasPermissions2;
this._setToggleValid(toggle, valid);
} else {
- toggle.checked = hasPermissions;
+ toggle.checked = hasPermissions2;
}
}
}
@@ -134,7 +135,7 @@ export class PermissionsToggleController {
/** */
async _updateValidity() {
- const permissions = await this._settingsController.permissionsUtil.getAllPermissions();
+ const permissions = await getAllPermissions();
this._onPermissionsChanged({permissions});
}