From b31060bbeb42424abfb1d02e463ec4dbb5b7f634 Mon Sep 17 00:00:00 2001 From: Bill Thornton Date: Mon, 28 Feb 2022 09:58:52 -0500 Subject: [PATCH] Fix remaining any type warnings --- src/apiclient.d.ts | 2 ++ .../dashboard/users/UserCardBox.tsx | 12 +++++----- src/components/search/SearchResultsRow.tsx | 23 ++++++++++++++++++- 3 files changed, 30 insertions(+), 7 deletions(-) diff --git a/src/apiclient.d.ts b/src/apiclient.d.ts index 565ac35a83..48cc65df0d 100644 --- a/src/apiclient.d.ts +++ b/src/apiclient.d.ts @@ -1,4 +1,5 @@ // TODO: Move to jellyfin-apiclient +/* eslint-disable @typescript-eslint/no-explicit-any */ declare module 'jellyfin-apiclient' { import { AllThemeMediaResult, @@ -348,3 +349,4 @@ declare module 'jellyfin-apiclient' { trigger(obj: any, eventName: string, ...args: any[]): void; }; } +/* eslint-enable @typescript-eslint/no-explicit-any */ diff --git a/src/components/dashboard/users/UserCardBox.tsx b/src/components/dashboard/users/UserCardBox.tsx index de5dac4084..ebfbc5998e 100644 --- a/src/components/dashboard/users/UserCardBox.tsx +++ b/src/components/dashboard/users/UserCardBox.tsx @@ -26,10 +26,10 @@ const createButtonElement = () => ({ }); type IProps = { - user?: Record; + user?: UserDto; } -const getLastSeenText = (lastActivityDate?: string) => { +const getLastSeenText = (lastActivityDate?: string | null) => { if (lastActivityDate) { return globalize.translate('LastSeen', formatDistanceToNow(Date.parse(lastActivityDate), localeWithSuffix)); } @@ -37,16 +37,16 @@ const getLastSeenText = (lastActivityDate?: string) => { return ''; }; -const UserCardBox: FunctionComponent = ({ user = [] }: IProps) => { +const UserCardBox: FunctionComponent = ({ user = {} }: IProps) => { let cssClass = 'card squareCard scalableCard squareCard-scalable'; - if (user.Policy.IsDisabled) { + if (user.Policy?.IsDisabled) { cssClass += ' grayscale'; } let imgUrl; - if (user.PrimaryImageTag) { + if (user.PrimaryImageTag && user.Id) { imgUrl = window.ApiClient.getUserImageUrl(user.Id, { width: 300, tag: user.PrimaryImageTag, @@ -56,7 +56,7 @@ const UserCardBox: FunctionComponent = ({ user = [] }: IProps) => { let imageClass = 'cardImage'; - if (user.Policy.IsDisabled) { + if (user.Policy?.IsDisabled) { imageClass += ' disabledUser'; } diff --git a/src/components/search/SearchResultsRow.tsx b/src/components/search/SearchResultsRow.tsx index 112b98e589..6830085052 100644 --- a/src/components/search/SearchResultsRow.tsx +++ b/src/components/search/SearchResultsRow.tsx @@ -16,10 +16,31 @@ const createScroller = ({ title = '' }) => ({ ` }); +type CardOptions = { + itemsContainer?: HTMLElement, + parentContainer?: HTMLElement, + allowBottomPadding?: boolean, + centerText?: boolean, + coverImage?: boolean, + inheritThumb?: boolean, + overlayMoreButton?: boolean, + overlayText?: boolean, + preferThumb?: boolean, + scalable?: boolean, + shape?: string, + showParentTitle?: boolean, + showParentTitleOrTitle?: boolean, + showAirTime?: boolean, + showAirDateTime?: boolean, + showChannelName?: boolean, + showTitle?: boolean, + showYear?: boolean +} + type SearchResultsRowProps = { title?: string; items?: BaseItemDto[]; - cardOptions?: Record; + cardOptions?: CardOptions; } const SearchResultsRow: FunctionComponent = ({ title, items = [], cardOptions = {} }: SearchResultsRowProps) => {