From 5c60f99077ce1dada3a4af10251766b677dc8e08 Mon Sep 17 00:00:00 2001 From: chinkara Date: Thu, 7 Mar 2024 10:12:27 +0100 Subject: [PATCH] Fix itemHelper by adding Enums and update function declation --- src/components/itemHelper.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/components/itemHelper.js b/src/components/itemHelper.js index 18c97c7fd4..498a8bab80 100644 --- a/src/components/itemHelper.js +++ b/src/components/itemHelper.js @@ -1,6 +1,10 @@ import { appHost } from './apphost'; import globalize from '../scripts/globalize'; import { CollectionType } from '@jellyfin/sdk/lib/generated-client/models/collection-type'; +import { BaseItemKind } from '@jellyfin/sdk/lib/generated-client/models/base-item-kind'; +import { LocationType } from '@jellyfin/sdk/lib/generated-client/models/location-type'; +import { RecordingStatus } from '@jellyfin/sdk/lib/generated-client/models/recording-status'; +import { MediaType } from '@jellyfin/sdk/lib/generated-client/models/media-type'; export function getDisplayName(item, options = {}) { if (!item) { @@ -156,26 +160,26 @@ export function canEditImages (user, item) { } export function canEditSubtitles (user, item) { - if (item.MediaType !== 'Video') { + if (item.MediaType !== MediaType.Video) { return false; } const itemType = item.Type; - if (itemType === 'Recording' && item.Status !== 'Completed') { + if (itemType === BaseItemKind.Recording && item.Status !== RecordingStatus.Completed) { return false; } - if (itemType === 'TvChannel' - || itemType === 'Program' + if (itemType === BaseItemKind.TvChannel + || itemType === BaseItemKind.Program || itemType === 'Timer' || itemType === 'SeriesTimer' - || itemType === 'UserRootFolder' - || itemType === 'UserView' + || itemType === BaseItemKind.UserRootFolder + || itemType === BaseItemKind.UserView ) { return false; } if (isLocalItem(item)) { return false; } - if (item.LocationType === 'Virtual') { + if (item.LocationType === LocationType.Virtual) { return false; } return user.Policy.EnableSubtitleManagement @@ -327,7 +331,7 @@ export default { canIdentify: canIdentify, canEdit: canEdit, canEditImages: canEditImages, - canEditSubtitles: canEditSubtitles, + canEditSubtitles, canShare: canShare, enableDateAddedDisplay: enableDateAddedDisplay, canMarkPlayed: canMarkPlayed,