fix: Fix folder media in timeline when camera is not timeline supported (#2246)

- Closes: #2205
This commit is contained in:
Dermot Duffy
2025-11-24 14:33:06 -08:00
committed by GitHub
parent f50bef7446
commit 1f6a4ddce2
20 changed files with 1011 additions and 421 deletions
@@ -6,7 +6,7 @@ import {
RichBrowseMedia,
} from '../../../ha/browse-media/types';
import parser from 'any-date-parser';
import type parser from 'any-date-parser';
import { isValidDate } from '../../../utils/basic';
import { regexpExtract } from '../../../utils/regexp-extract';
import { REGEXP_GROUP_VALUE_KEY } from './types';
+6 -3
View File
@@ -22,10 +22,13 @@ export class FolderInitializationError extends AdvancedCameraCardError {}
// Folder Query
// ============
export type FolderPathComponent = {
folder?: ViewFolder;
interface FolderPathComponentMetadata {
ha?: HAFolderPathComponent;
};
}
export interface FolderPathComponent extends FolderPathComponentMetadata {
folder?: ViewFolder;
}
export interface FolderQuery {
folder: FolderConfig;
+17 -8
View File
@@ -6,7 +6,6 @@ import { View, ViewParameters } from '../../view/view';
import {
getCameraIDsForViewName,
isViewSupportedByCamera,
isViewSupportedByQueryOnly,
} from '../../view/view-support';
import { CardViewAPI } from '../types';
import { applyViewModifiers } from './modifiers';
@@ -36,7 +35,11 @@ export class ViewFactory {
cameraID = options.params.camera;
} else {
const cameraIDs = [
...getCameraIDsForViewName(viewName, this._api.getCameraManager()),
...getCameraIDsForViewName(
viewName,
this._api.getCameraManager(),
this._api.getFoldersManager(),
),
];
if (
@@ -79,10 +82,11 @@ export class ViewFactory {
const viewCameraIDs = getCameraIDsForViewName(
viewName,
this._api.getCameraManager(),
this._api.getFoldersManager(),
);
// Reset to the default camera.
cameraID = viewCameraIDs.keys().next().value ?? null;
cameraID = viewCameraIDs?.keys().next().value ?? null;
}
if (!cameraID) {
@@ -103,16 +107,21 @@ export class ViewFactory {
}
if (
!isViewSupportedByCamera(viewName, this._api.getCameraManager(), cameraID) &&
!isViewSupportedByQueryOnly(
!isViewSupportedByCamera(
viewName,
options?.params?.query ?? options?.baseView?.query,
options?.params?.queryResults ?? options?.baseView?.queryResults,
this._api.getCameraManager(),
this._api.getFoldersManager(),
cameraID,
)
) {
if (
options?.failSafe &&
isViewSupportedByCamera(VIEW_DEFAULT, this._api.getCameraManager(), cameraID)
isViewSupportedByCamera(
VIEW_DEFAULT,
this._api.getCameraManager(),
this._api.getFoldersManager(),
cameraID,
)
) {
viewName = VIEW_DEFAULT;
} else {