1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

Fix eslint warnings in ts files

This commit is contained in:
Bill Thornton 2023-04-26 11:30:57 -04:00
parent 097471863e
commit 8f730b8270
5 changed files with 14 additions and 8 deletions

View file

@ -4,6 +4,7 @@ import { useLocation } from 'react-router-dom';
import ServerConnections from './ServerConnections';
import viewManager from './viewManager/viewManager';
import globalize from '../scripts/globalize';
import type { RestoreViewFailResponse } from '../types/viewManager';
interface ServerContentPageProps {
view: string
@ -29,7 +30,7 @@ const ServerContentPage: FunctionComponent<ServerContentPageProps> = ({ view })
};
viewManager.tryRestoreView(viewOptions)
.catch(async (result?: any) => {
.catch(async (result?: RestoreViewFailResponse) => {
if (!result || !result.cancelled) {
const apiClient = ServerConnections.currentApiClient();

View file

@ -2,6 +2,7 @@ import React, { FunctionComponent, useEffect } from 'react';
import { useLocation } from 'react-router-dom';
import globalize from '../../scripts/globalize';
import type { RestoreViewFailResponse } from '../../types/viewManager';
import viewManager from './viewManager';
export interface ViewManagerPageProps {
@ -45,7 +46,7 @@ const ViewManagerPage: FunctionComponent<ViewManagerPageProps> = ({
};
viewManager.tryRestoreView(viewOptions)
.catch(async (result?: any) => {
.catch(async (result?: RestoreViewFailResponse) => {
if (!result || !result.cancelled) {
const [ controllerFactory, viewHtml ] = await Promise.all([
import(/* webpackChunkName: "[request]" */ `../../controllers/${controller}`),

View file

@ -126,7 +126,7 @@ const Scroller: FC<ScrollerProps> = ({
}, [getScrollPosition, getScrollSize, getScrollWidth]);
const initCenterFocus = useCallback((elem: EventTarget, scrollerInstance: scrollerFactory) => {
dom.addEventListener(elem, 'focus', function (e: { target: any; }) {
dom.addEventListener(elem, 'focus', function (e: FocusEvent) {
const focused = focusManager.focusableParent(e.target);
if (focused) {
scrollerInstance.toCenter(focused, false);

3
src/types/viewManager.ts Normal file
View file

@ -0,0 +1,3 @@
export interface RestoreViewFailResponse {
cancelled?: boolean
}

View file

@ -31,25 +31,26 @@ function getItemsSplit(apiClient: ApiClient, userId: string, options: GetItemsRe
function mergeResults(results: BaseItemDtoQueryResult[]) {
const merged: BaseItemDtoQueryResult = {
Items: [],
TotalRecordCount: 0,
StartIndex: 0
};
// set TotalRecordCount separately so TS knows it is defined
merged.TotalRecordCount = 0;
for (const result of results) {
if (result.Items == null) {
if (!result.Items) {
console.log('[getItems] Retrieved Items array is invalid', result.Items);
continue;
}
if (result.TotalRecordCount == null) {
if (!result.TotalRecordCount) {
console.log('[getItems] Retrieved TotalRecordCount is invalid', result.TotalRecordCount);
continue;
}
if (result.StartIndex == null) {
if (typeof result.StartIndex === 'undefined') {
console.log('[getItems] Retrieved StartIndex is invalid', result.StartIndex);
continue;
}
merged.Items = merged.Items?.concat(result.Items);
merged.TotalRecordCount! += result.TotalRecordCount;
merged.TotalRecordCount += result.TotalRecordCount;
merged.StartIndex = Math.min(merged.StartIndex || 0, result.StartIndex);
}
return merged;