Rename file level constant to conform naming conv.

Renames idsPerItemRequestLimit to ITEMS_PER_REQUEST_LIMIT
as it as a file level constant.
This commit is contained in:
Merlin Danner 2023-03-29 06:29:37 +02:00
parent 39ceb2ae2e
commit 96febf9f25

View file

@ -1,7 +1,7 @@
import type {BaseItemDtoQueryResult} from '@jellyfin/sdk/lib/generated-client'; import type {BaseItemDtoQueryResult} from '@jellyfin/sdk/lib/generated-client';
import {ApiClient} from 'jellyfin-apiclient'; import {ApiClient} from 'jellyfin-apiclient';
const idsPerItemRequestLimit = 25; const ITEMS_PER_REQUEST_LIMIT = 25;
function getItemsSplit(apiClient: ApiClient, userId: string, options: any) { function getItemsSplit(apiClient: ApiClient, userId: string, options: any) {
const optionsTemplate = {...options}; const optionsTemplate = {...options};
@ -10,7 +10,7 @@ function getItemsSplit(apiClient: ApiClient, userId: string, options: any) {
let nextI; let nextI;
for (let i = 0; i < ids.length && i < options.Limit; i = nextI) { for (let i = 0; i < ids.length && i < options.Limit; i = nextI) {
nextI = i + idsPerItemRequestLimit; nextI = i + ITEMS_PER_REQUEST_LIMIT;
if (nextI > options.Limit) { if (nextI > options.Limit) {
nextI = options.Limit; nextI = options.Limit;
} }
@ -52,7 +52,7 @@ function mergeResults(results: BaseItemDtoQueryResult[]) {
export function getItems(apiClient: ApiClient, userId: string, options?: any): export function getItems(apiClient: ApiClient, userId: string, options?: any):
Promise<BaseItemDtoQueryResult> { Promise<BaseItemDtoQueryResult> {
if (options.Ids === undefined || if (options.Ids === undefined ||
options.Ids.split(',').length <= idsPerItemRequestLimit) { options.Ids.split(',').length <= ITEMS_PER_REQUEST_LIMIT) {
return apiClient.getItems(apiClient.getCurrentUserId(), options); return apiClient.getItems(apiClient.getCurrentUserId(), options);
} }
const results = getItemsSplit(apiClient, userId, options); const results = getItemsSplit(apiClient, userId, options);