diff --git a/src/components/activitylog.js b/src/components/activitylog.js index b48b364fc7..42a790280a 100644 --- a/src/components/activitylog.js +++ b/src/components/activitylog.js @@ -9,6 +9,7 @@ import '../elements/emby-button/emby-button'; import './listview/listview.scss'; import ServerConnections from './ServerConnections'; import alert from './alert'; +import { toBoolean } from '../utils/string.ts'; /* eslint-disable indent */ @@ -68,7 +69,7 @@ import alert from './alert'; limit = limit || parseInt(elem.getAttribute('data-activitylimit') || '7'); const minDate = new Date(); - const hasUserId = elem.getAttribute('data-useractivity') !== 'false'; + const hasUserId = toBoolean(elem.getAttribute('data-useractivity'), true); // TODO: Use date-fns if (hasUserId) { diff --git a/src/components/dialogHelper/dialogHelper.js b/src/components/dialogHelper/dialogHelper.js index 8a6a22fd15..59b249b8f5 100644 --- a/src/components/dialogHelper/dialogHelper.js +++ b/src/components/dialogHelper/dialogHelper.js @@ -3,7 +3,9 @@ import focusManager from '../focusManager'; import browser from '../../scripts/browser'; import layoutManager from '../layoutManager'; import inputManager from '../../scripts/inputManager'; +import { toBoolean } from '../../utils/string.ts'; import dom from '../../scripts/dom'; + import './dialoghelper.scss'; import '../../assets/css/scrollstyles.scss'; @@ -95,7 +97,7 @@ import '../../assets/css/scrollstyles.scss'; focusManager.focus(activeElement); } - if (dlg.getAttribute('data-removeonclose') !== 'false') { + if (toBoolean(dlg.getAttribute('data-removeonclose'), true)) { removeCenterFocus(dlg); const dialogContainer = dlg.dialogContainer; diff --git a/src/controllers/dashboard/serveractivity.js b/src/controllers/dashboard/serveractivity.js index 1f44b9eefb..e8471999dd 100644 --- a/src/controllers/dashboard/serveractivity.js +++ b/src/controllers/dashboard/serveractivity.js @@ -1,12 +1,13 @@ import ActivityLog from '../../components/activitylog'; import globalize from '../../scripts/globalize'; +import { toBoolean } from '../../utils/string.ts'; /* eslint-disable indent */ export default function (view, params) { let activityLog; - if (params.useractivity !== 'false') { + if (toBoolean(params.useractivity, true)) { view.querySelector('.activityItems').setAttribute('data-useractivity', 'true'); view.querySelector('.sectionTitle').innerHTML = globalize.translate('HeaderActivity'); } else { diff --git a/src/scripts/settings/appSettings.js b/src/scripts/settings/appSettings.js index 7b59c35f3c..5ebf98100a 100644 --- a/src/scripts/settings/appSettings.js +++ b/src/scripts/settings/appSettings.js @@ -1,5 +1,5 @@ -/* eslint-disable indent */ import { AppStorage, Events } from 'jellyfin-apiclient'; +import { toBoolean } from '../../utils/string.ts'; class AppSettings { #getKey(name, userId) { @@ -15,7 +15,7 @@ class AppSettings { this.set('enableAutoLogin', val.toString()); } - return this.get('enableAutoLogin') !== 'false'; + return toBoolean(this.get('enableAutoLogin'), true); } /** @@ -28,7 +28,7 @@ class AppSettings { return this.set('enableGamepad', val.toString()); } - return this.get('enableGamepad') === 'true'; + return toBoolean(this.get('enableGamepad'), false); } enableSystemExternalPlayers(val) { @@ -36,7 +36,7 @@ class AppSettings { this.set('enableSystemExternalPlayers', val.toString()); } - return this.get('enableSystemExternalPlayers') === 'true'; + return toBoolean(this.get('enableSystemExternalPlayers'), false); } enableAutomaticBitrateDetection(isInNetwork, mediaType, val) { @@ -52,7 +52,7 @@ class AppSettings { if (isInNetwork && mediaType === 'Audio') { return true; } else { - return this.get(key) !== 'false'; + return toBoolean(this.get(key), true); } } @@ -106,6 +106,4 @@ class AppSettings { } } -/* eslint-enable indent */ - export default new AppSettings(); diff --git a/src/scripts/settings/userSettings.js b/src/scripts/settings/userSettings.js index 0a755d1da2..cff3be87c0 100644 --- a/src/scripts/settings/userSettings.js +++ b/src/scripts/settings/userSettings.js @@ -1,5 +1,6 @@ import appSettings from './appSettings'; import { Events } from 'jellyfin-apiclient'; +import { toBoolean } from '../../utils/string.ts'; function onSaveTimeout() { const self = this; @@ -134,8 +135,7 @@ export class UserSettings { return this.set('preferFmp4HlsContainer', val.toString(), false); } - val = this.get('preferFmp4HlsContainer', false); - return val === 'true'; + return toBoolean(this.get('preferFmp4HlsContainer', false), false); } /** @@ -148,8 +148,7 @@ export class UserSettings { return this.set('enableCinemaMode', val.toString(), false); } - val = this.get('enableCinemaMode', false); - return val !== 'false'; + return toBoolean(this.get('enableCinemaMode', false), true); } /** @@ -162,8 +161,7 @@ export class UserSettings { return this.set('enableNextVideoInfoOverlay', val.toString()); } - val = this.get('enableNextVideoInfoOverlay', false); - return val !== 'false'; + return toBoolean(this.get('enableNextVideoInfoOverlay', false), true); } /** @@ -176,7 +174,7 @@ export class UserSettings { return this.set('enableSetUsingLastTracks', val.toString()); } - return this.get('enableSetUsingLastTracks', false) !== 'false'; + return toBoolean(this.get('enableSetUsingLastTracks', false), true); } /** @@ -189,8 +187,7 @@ export class UserSettings { return this.set('enableThemeSongs', val.toString(), false); } - val = this.get('enableThemeSongs', false); - return val === 'true'; + return toBoolean(this.get('enableThemeSongs', false), false); } /** @@ -203,8 +200,7 @@ export class UserSettings { return this.set('enableThemeVideos', val.toString(), false); } - val = this.get('enableThemeVideos', false); - return val === 'true'; + return toBoolean(this.get('enableThemeVideos', false), false); } /** @@ -217,8 +213,7 @@ export class UserSettings { return this.set('fastFadein', val.toString(), false); } - val = this.get('fastFadein', false); - return val !== 'false'; + return toBoolean(this.get('fastFadein', false), true); } /** @@ -231,8 +226,7 @@ export class UserSettings { return this.set('blurhash', val.toString(), false); } - val = this.get('blurhash', false); - return val !== 'false'; + return toBoolean(this.get('blurhash', false), true); } /** @@ -245,8 +239,7 @@ export class UserSettings { return this.set('enableBackdrops', val.toString(), false); } - val = this.get('enableBackdrops', false); - return val === 'true'; + return toBoolean(this.get('enableBackdrops', false), false); } /** @@ -259,7 +252,7 @@ export class UserSettings { return this.set('disableCustomCss', val.toString(), false); } - return this.get('disableCustomCss', false) === 'true'; + return toBoolean(this.get('disableCustomCss', false), false); } /** @@ -285,8 +278,7 @@ export class UserSettings { return this.set('detailsBanner', val.toString(), false); } - val = this.get('detailsBanner', false); - return val !== 'false'; + return toBoolean(this.get('detailsBanner', false), true); } /** @@ -299,8 +291,7 @@ export class UserSettings { return this.set('useEpisodeImagesInNextUpAndResume', val.toString(), true); } - val = this.get('useEpisodeImagesInNextUpAndResume', true); - return val === 'true'; + return toBoolean(this.get('useEpisodeImagesInNextUpAndResume', true), false); } /** @@ -468,7 +459,7 @@ export class UserSettings { return this.set('enableRewatchingInNextUp', val, false); } - return this.get('enableRewatchingInNextUp', false) === 'true'; + return toBoolean(this.get('enableRewatchingInNextUp', false), false); } /**