Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions src/components/device-image/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,12 @@ type ImageGeneratorFn = (device: Device) => string | undefined;
const z2mBasePath = 'https://www.zigbee2mqtt.io/images/devices/';

export const getZ2mDeviceImage = (device: Device): string =>
`${z2mBasePath}${sanitizeZ2MDeviceName(device?.definition?.model)}.jpg`;
export const getZ2mDeviceImagePng = (device: Device): string =>
`${z2mBasePath}${sanitizeZ2MDeviceName(device?.definition?.model)}.png`;
const getConverterDeviceImage = (device: Device): string | undefined => device.definition?.icon;

/* prettier-ignore */
export const AVAILABLE_GENERATORS: ImageGeneratorFn[] = [
getConverterDeviceImage,
getZ2mDeviceImagePng,
getZ2mDeviceImage,
() => genericDevice,
];
4 changes: 2 additions & 2 deletions src/components/settings-page/image-localiser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Button from '../button';
import { Device, IEEEEAddress } from '../../types';
import { WithDevices } from '../../store';
import { DeviceApi } from '../../actions/DeviceApi';
import { getZ2mDeviceImage, getZ2mDeviceImagePng } from '../device-image';
import { getZ2mDeviceImage } from '../device-image';

type LocaliserState = 'none' | 'start' | 'inprogress' | 'done';

Expand Down Expand Up @@ -52,7 +52,7 @@ function ImageLocaliser(props: Props): JSX.Element {
setLocalisationStatus((curr) => {
return { ...curr, [device.ieee_address]: 'init' };
});
const success = await asyncSome([getZ2mDeviceImagePng, getZ2mDeviceImage], async (generator) => {
const success = await asyncSome([getZ2mDeviceImage], async (generator) => {
const imageUrl = generator(device);
const imageContent = await downloadImage(imageUrl);
await setDeviceOptions(device.ieee_address, { icon: imageContent });
Expand Down
Loading