From c030cbe204090cea3ac171ec5f4e350261d20088 Mon Sep 17 00:00:00 2001 From: Anton Nikolaev Date: Thu, 12 Dec 2019 03:59:57 -0800 Subject: [PATCH] No Icons on Windows with locale other than en-US Reviewed By: mweststrate Differential Revision: D18953063 fbshipit-source-id: d21116b11189851dff271fcfa7334a51b13c693f --- src/utils/icons.js | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/src/utils/icons.js b/src/utils/icons.js index d9191fe86..33519acde 100644 --- a/src/utils/icons.js +++ b/src/utils/icons.js @@ -98,13 +98,20 @@ function getIconPartsFromName(icon) { 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 function buildLocalIconPath(name, size, density) { const icon = getIconPartsFromName(name); - return path.join( - 'icons', - `${icon.trimmedName}-${icon.variant}-${size}@${density}x.png`, - ); + return path.join('icons', getIconFileName(icon, size, density)); +} + +// $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 @@ -168,13 +175,17 @@ module.exports = { } } - const localPath = buildLocalIconPath(name, size, density); // resolve icon locally if possible if ( 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); },