summaryrefslogtreecommitdiff
path: root/ext/js/pages/settings/backup-controller.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2024-02-27 07:23:42 -0500
committerGitHub <noreply@github.com>2024-02-27 12:23:42 +0000
commite47a0f488f3d9bbcb76ebcf4f5afe203c1ee06c0 (patch)
tree35a4a7411dd3154b19316b330c4976f291f021d2 /ext/js/pages/settings/backup-controller.js
parente74fadc5a411e907da088729ea13e23e6f5aa58d (diff)
Object utilities (#729)
* Create utilities * Rename old isObject * Use new isObject * Remove old function * Add additional function * Simplify for now * Rename function for clarity * Rename function * Expand type * Update eslint
Diffstat (limited to 'ext/js/pages/settings/backup-controller.js')
-rw-r--r--ext/js/pages/settings/backup-controller.js16
1 files changed, 8 insertions, 8 deletions
diff --git a/ext/js/pages/settings/backup-controller.js b/ext/js/pages/settings/backup-controller.js
index 2a0706e4..dd739d39 100644
--- a/ext/js/pages/settings/backup-controller.js
+++ b/ext/js/pages/settings/backup-controller.js
@@ -19,8 +19,8 @@
import {Dexie} from '../../../lib/dexie.js';
import {parseJson} from '../../core/json.js';
import {log} from '../../core/log.js';
+import {isObjectNotArray} from '../../core/object-utilities.js';
import {toError} from '../../core/to-error.js';
-import {isObject} from '../../core/utilities.js';
import {OptionsUtil} from '../../data/options-util.js';
import {getAllPermissions} from '../../data/permissions-util.js';
import {arrayBufferUtf8Decode} from '../../data/sandbox/array-buffer-util.js';
@@ -354,7 +354,7 @@ export class BackupController {
const warnings = [];
const anki = options.anki;
- if (isObject(anki)) {
+ if (isObjectNotArray(anki)) {
const fieldTemplates = anki.fieldTemplates;
if (typeof fieldTemplates === 'string') {
warnings.push('anki.fieldTemplates contains a non-default value');
@@ -372,12 +372,12 @@ export class BackupController {
}
const audio = options.audio;
- if (isObject(audio)) {
+ if (isObjectNotArray(audio)) {
const sources = audio.sources;
if (Array.isArray(sources)) {
for (let i = 0, ii = sources.length; i < ii; ++i) {
const source = sources[i];
- if (!isObject(source)) { continue; }
+ if (!isObjectNotArray(source)) { continue; }
const {url} = source;
if (typeof url === 'string' && url.length > 0 && !this._isLocalhostUrl(url)) {
warnings.push(`audio.sources[${i}].url uses a non-localhost URL`);
@@ -403,9 +403,9 @@ export class BackupController {
const profiles = optionsFull.profiles;
if (Array.isArray(profiles)) {
for (const profile of profiles) {
- if (!isObject(profile)) { continue; }
+ if (!isObjectNotArray(profile)) { continue; }
const options = profile.options;
- if (!isObject(options)) { continue; }
+ if (!isObjectNotArray(options)) { continue; }
const warnings2 = this._settingsImportSanitizeProfileOptions(options, dryRun);
for (const warning of warnings2) {
@@ -428,7 +428,7 @@ export class BackupController {
const data = parseJson(dataString);
// Type check
- if (!isObject(data)) {
+ if (!isObjectNotArray(data)) {
throw new Error(`Invalid data type: ${typeof data}`);
}
@@ -451,7 +451,7 @@ export class BackupController {
// Verify options exists
let optionsFull = data.options;
- if (!isObject(optionsFull)) {
+ if (!isObjectNotArray(optionsFull)) {
throw new Error(`Invalid options type: ${typeof optionsFull}`);
}