No Icons on Windows with locale other than en-US

Reviewed By: mweststrate

Differential Revision: D18953063

fbshipit-source-id: d21116b11189851dff271fcfa7334a51b13c693f
This commit is contained in:
Anton Nikolaev
2019-12-12 03:59:57 -08:00
committed by Facebook Github Bot
parent 559285f5f9
commit c030cbe204

View File

@@ -98,13 +98,20 @@ function getIconPartsFromName(icon) {
return {trimmedName: trimmedName, variant: variant}; return {trimmedName: trimmedName, variant: variant};
} }
function getIconFileName(icon, size, density) {
return `${icon.trimmedName}-${icon.variant}-${size}@${density}x.png`;
}
// $FlowFixMe not using flow in this file // $FlowFixMe not using flow in this file
function buildLocalIconPath(name, size, density) { function buildLocalIconPath(name, size, density) {
const icon = getIconPartsFromName(name); const icon = getIconPartsFromName(name);
return path.join( return path.join('icons', getIconFileName(icon, size, density));
'icons', }
`${icon.trimmedName}-${icon.variant}-${size}@${density}x.png`,
); // $FlowFixMe not using flow in this file
function buildLocalIconURL(name, size, density) {
const icon = getIconPartsFromName(name);
return `icons/${getIconFileName(icon, size, density)}`;
} }
// $FlowFixMe not using flow in this file // $FlowFixMe not using flow in this file
@@ -168,13 +175,17 @@ module.exports = {
} }
} }
const localPath = buildLocalIconPath(name, size, density);
// resolve icon locally if possible // resolve icon locally if possible
if ( if (
remote && remote &&
fs.existsSync(path.join(remote.app.getAppPath(), localPath)) fs.existsSync(
path.join(
remote.app.getAppPath(),
buildLocalIconPath(name, size, density),
),
)
) { ) {
return localPath; return buildLocalIconURL(name, size, density);
} }
return buildIconURL(name, requestedSize, density); return buildIconURL(name, requestedSize, density);
}, },