mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-03 23:46:34 +00:00
Cache the camera url without the width and height added (#9778)
This commit is contained in:
parent
e08f691510
commit
f6d02d8fc6
@ -36,30 +36,28 @@ export interface Stream {
|
|||||||
export const computeMJPEGStreamUrl = (entity: CameraEntity) =>
|
export const computeMJPEGStreamUrl = (entity: CameraEntity) =>
|
||||||
`/api/camera_proxy_stream/${entity.entity_id}?token=${entity.attributes.access_token}`;
|
`/api/camera_proxy_stream/${entity.entity_id}?token=${entity.attributes.access_token}`;
|
||||||
|
|
||||||
export const fetchThumbnailUrlWithCache = (
|
export const fetchThumbnailUrlWithCache = async (
|
||||||
hass: HomeAssistant,
|
|
||||||
entityId: string,
|
|
||||||
width: number,
|
|
||||||
height: number
|
|
||||||
) =>
|
|
||||||
timeCachePromiseFunc(
|
|
||||||
"_cameraTmbUrl",
|
|
||||||
9000,
|
|
||||||
fetchThumbnailUrl,
|
|
||||||
hass,
|
|
||||||
entityId,
|
|
||||||
width,
|
|
||||||
height
|
|
||||||
);
|
|
||||||
|
|
||||||
export const fetchThumbnailUrl = async (
|
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
entityId: string,
|
entityId: string,
|
||||||
width: number,
|
width: number,
|
||||||
height: number
|
height: number
|
||||||
|
) => {
|
||||||
|
const base_url = await timeCachePromiseFunc(
|
||||||
|
"_cameraTmbUrl",
|
||||||
|
9000,
|
||||||
|
fetchThumbnailUrl,
|
||||||
|
hass,
|
||||||
|
entityId
|
||||||
|
);
|
||||||
|
return `${base_url}&width=${width}&height=${height}`;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const fetchThumbnailUrl = async (
|
||||||
|
hass: HomeAssistant,
|
||||||
|
entityId: string
|
||||||
) => {
|
) => {
|
||||||
const path = await getSignedPath(hass, `/api/camera_proxy/${entityId}`);
|
const path = await getSignedPath(hass, `/api/camera_proxy/${entityId}`);
|
||||||
return hass.hassUrl(`${path.path}&width=${width}&height=${height}`);
|
return hass.hassUrl(path.path);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const fetchStreamUrl = async (
|
export const fetchStreamUrl = async (
|
||||||
|
Loading…
x
Reference in New Issue
Block a user