2017-05-07 09:49:15 +02:00
|
|
|
import log from 'loglevel';
|
2018-07-21 15:16:02 +02:00
|
|
|
import { inferIcon } from '../../infer';
|
2017-05-07 09:49:15 +02:00
|
|
|
|
2018-05-24 09:02:44 +02:00
|
|
|
export default function({ icon, targetUrl, platform }) {
|
2017-05-07 09:49:15 +02:00
|
|
|
// Icon is the path to the icon
|
|
|
|
if (icon) {
|
2017-05-19 14:50:09 +02:00
|
|
|
return Promise.resolve(icon);
|
2017-05-07 09:49:15 +02:00
|
|
|
}
|
|
|
|
|
2018-05-24 09:02:44 +02:00
|
|
|
return inferIcon(targetUrl, platform).catch((error) => {
|
|
|
|
log.warn('Cannot automatically retrieve the app icon:', error);
|
|
|
|
return null;
|
|
|
|
});
|
2017-05-07 09:49:15 +02:00
|
|
|
}
|