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:
parent
097471863e
commit
8f730b8270
5 changed files with 14 additions and 8 deletions
|
@ -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();
|
||||
|
||||
|
|
|
@ -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}`),
|
||||
|
|
|
@ -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
3
src/types/viewManager.ts
Normal file
|
@ -0,0 +1,3 @@
|
|||
export interface RestoreViewFailResponse {
|
||||
cancelled?: boolean
|
||||
}
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue