fix: Remove the unnecessary item limit from folder media (#2688)
- Fixed: #2573
This commit is contained in:
@@ -166,7 +166,6 @@ export class HAFoldersEngine implements FoldersEngine {
|
||||
targets: BrowseMediaTarget<BrowseMediaMetadata>[],
|
||||
): BrowseMediaStep<BrowseMediaMetadata>[] => {
|
||||
const nextComponent = pathComponents.shift();
|
||||
const limit = query.limit ?? null;
|
||||
|
||||
return [
|
||||
{
|
||||
@@ -174,11 +173,6 @@ export class HAFoldersEngine implements FoldersEngine {
|
||||
metadataGenerator: (media, parent) =>
|
||||
this._metadataGenerator.generate(media, parent, nextComponent?.ha?.parsers),
|
||||
|
||||
// At the final step (no nextComponent), apply limit via earlyExit.
|
||||
...(limit && {
|
||||
earlyExit: (media) => media.length >= limit,
|
||||
}),
|
||||
|
||||
...(nextComponent && {
|
||||
matcher: (media) =>
|
||||
this._mediaMatcher.match(hass, media, {
|
||||
@@ -202,11 +196,10 @@ export class HAFoldersEngine implements FoldersEngine {
|
||||
},
|
||||
);
|
||||
|
||||
const results = getViewItemsFromBrowseMediaArray(browseMedia, {
|
||||
return getViewItemsFromBrowseMediaArray(browseMedia, {
|
||||
folder: query.folder,
|
||||
path: query.path,
|
||||
});
|
||||
return query.limit ? results.slice(0, query.limit) : results;
|
||||
}
|
||||
|
||||
public generateChildFolderQuery(
|
||||
|
||||
@@ -39,7 +39,6 @@ export interface FolderQuery extends BaseQuery, QueryFilters {
|
||||
// A trail of paths to navigate back to the "root", with the last path being
|
||||
// the path that this query directly refers to.
|
||||
path: NonEmptyTuple<FolderPathComponent>;
|
||||
limit?: number;
|
||||
}
|
||||
|
||||
// ===============
|
||||
|
||||
@@ -205,9 +205,7 @@ export class ViewQueryExecutor {
|
||||
case 'folders':
|
||||
viewModifiers.push(
|
||||
...(await executeQuery(
|
||||
builder.buildDefaultFolderQuery(queryExecutorOptions?.folder, {
|
||||
limit: this._getLimit(),
|
||||
}),
|
||||
builder.buildDefaultFolderQuery(queryExecutorOptions?.folder),
|
||||
)),
|
||||
);
|
||||
break;
|
||||
|
||||
@@ -10,8 +10,6 @@ import type { UnifiedQueryBuilder } from '../view/unified-query-builder';
|
||||
export interface FolderNavigationParamaters {
|
||||
viewManagerEpoch: ViewManagerEpoch;
|
||||
builder: UnifiedQueryBuilder;
|
||||
|
||||
limit?: number;
|
||||
}
|
||||
|
||||
export interface MediaNavigationParamaters {
|
||||
@@ -51,9 +49,6 @@ export const navigateUp = (options?: FolderNavigationParamaters | null): void =>
|
||||
const query = options?.builder.buildFolderQueryWithPath(
|
||||
folderQuery.folder,
|
||||
nonEmptyPath,
|
||||
{
|
||||
limit: options?.limit,
|
||||
},
|
||||
);
|
||||
|
||||
void options?.viewManagerEpoch.manager.setViewByParametersWithExistingQuery({
|
||||
@@ -73,9 +68,6 @@ export const navigateToFolder = (
|
||||
const query = options?.builder.buildFolderQueryWithPath(
|
||||
item.getFolder(),
|
||||
nonEmptyPath,
|
||||
{
|
||||
limit: options?.limit,
|
||||
},
|
||||
);
|
||||
|
||||
void options?.viewManagerEpoch?.manager.setViewByParametersWithExistingQuery({
|
||||
|
||||
@@ -26,7 +26,6 @@ import {
|
||||
import type { ConditionStateManagerReadonlyInterface } from '../../condition-trigger/conditions/types.js';
|
||||
import type { MediaGalleryConfig } from '../../config/schema/media-gallery.js';
|
||||
import type { CardWideConfig } from '../../config/schema/types.js';
|
||||
import { MEDIA_CHUNK_SIZE_DEFAULT } from '../../const.js';
|
||||
import type { HomeAssistant } from '../../ha/types.js';
|
||||
import galleryStyle from '../../scss/gallery.scss?inline';
|
||||
import { stopEventFromActivatingCardWideActions } from '../../utils/action.js';
|
||||
@@ -101,19 +100,11 @@ export class AdvancedCameraCardGallery extends LitElement {
|
||||
}
|
||||
}
|
||||
|
||||
private _getLimit(): number {
|
||||
return (
|
||||
this.cardWideConfig?.performance?.features?.media_chunk_size ??
|
||||
MEDIA_CHUNK_SIZE_DEFAULT
|
||||
);
|
||||
}
|
||||
|
||||
private _getFolderNavigationParameters(): FolderNavigationParamaters | null {
|
||||
return this._builder && this.viewManagerEpoch
|
||||
? {
|
||||
builder: this._builder,
|
||||
viewManagerEpoch: this.viewManagerEpoch,
|
||||
limit: this._getLimit(),
|
||||
}
|
||||
: null;
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@ import {
|
||||
} from '../components-lib/navigation.js';
|
||||
import type { ThumbnailsControlConfig } from '../config/schema/common/controls/thumbnails.js';
|
||||
import type { CardWideConfig } from '../config/schema/types.js';
|
||||
import { MEDIA_CHUNK_SIZE_DEFAULT } from '../const.js';
|
||||
import type { HomeAssistant } from '../ha/types.js';
|
||||
import thumbnailCarouselStyle from '../scss/thumbnail-carousel.scss?inline';
|
||||
import { stopEventFromActivatingCardWideActions } from '../utils/action.js';
|
||||
@@ -73,19 +72,11 @@ export class AdvancedCameraCardThumbnailCarousel extends LitElement {
|
||||
private _thumbnails: TemplateResult[] = [];
|
||||
private _builder: UnifiedQueryBuilder | null = null;
|
||||
|
||||
private _getLimit(): number {
|
||||
return (
|
||||
this.cardWideConfig?.performance?.features?.media_chunk_size ??
|
||||
MEDIA_CHUNK_SIZE_DEFAULT
|
||||
);
|
||||
}
|
||||
|
||||
private _getFolderNavOptions(): FolderNavigationParamaters | undefined {
|
||||
return this._builder && this.viewManagerEpoch
|
||||
? {
|
||||
builder: this._builder,
|
||||
viewManagerEpoch: this.viewManagerEpoch,
|
||||
limit: this._getLimit(),
|
||||
}
|
||||
: undefined;
|
||||
}
|
||||
|
||||
@@ -267,14 +267,12 @@ export class UnifiedQueryBuilder {
|
||||
public buildFolderQueryWithPath(
|
||||
folder: FolderConfig,
|
||||
path: NonEmptyTuple<FolderPathComponent>,
|
||||
options?: QueryFiltersOptions,
|
||||
): UnifiedQuery {
|
||||
const query = new UnifiedQuery();
|
||||
const folderQuery: FolderQuery = {
|
||||
source: QuerySource.Folder,
|
||||
folder,
|
||||
path,
|
||||
...(options?.limit !== undefined && { limit: options.limit }),
|
||||
};
|
||||
query.addNode(folderQuery);
|
||||
return query;
|
||||
@@ -282,7 +280,7 @@ export class UnifiedQueryBuilder {
|
||||
|
||||
public buildDefaultFolderQuery(
|
||||
folderID?: string,
|
||||
options?: QueryFiltersOptions,
|
||||
options?: QueryFilters,
|
||||
): UnifiedQuery | null {
|
||||
const query = new UnifiedQuery();
|
||||
this._addNode(query, this._buildFolderQueryNode(folderID, options));
|
||||
@@ -317,7 +315,7 @@ export class UnifiedQueryBuilder {
|
||||
return params
|
||||
? {
|
||||
...params,
|
||||
...options,
|
||||
...this._extractFilterOptions(options),
|
||||
}
|
||||
: null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user