From 88dc7bb6b9612b8b5e7a9f8ba98c889e43ed4b1a Mon Sep 17 00:00:00 2001 From: Ben Gotow Date: Sun, 16 Jun 2019 13:24:46 -0500 Subject: [PATCH] =?UTF-8?q?Sentry=20fix:=20=E2=80=9CCannot=20read=20proper?= =?UTF-8?q?ty=20'split'=20of=20undefined=E2=80=9D=20in=20linux=20theme=20r?= =?UTF-8?q?esolution?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/linux-theme-utils.ts | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/app/src/linux-theme-utils.ts b/app/src/linux-theme-utils.ts index ef7653157..7d0ebd882 100644 --- a/app/src/linux-theme-utils.ts +++ b/app/src/linux-theme-utils.ts @@ -244,25 +244,27 @@ function getIconFromTheme( */ function getIconPath(iconName: string, size: number, context: string | string[], scale: 1 | 2 = 1) { let defaultTheme = getIconTheme(getIconThemeName()); - if (defaultTheme != null) { - let inherits = defaultTheme.data['Icon Theme']['Inherits'].split(','); + if (!defaultTheme) return null; - let icon = getIconFromTheme(defaultTheme, iconName, size, context, scale); + const iconThemeObject = defaultTheme.data['Icon Theme']; + const inheritsList = iconThemeObject && iconThemeObject['Inherits']; + if (!inheritsList) return null; + const inherits = inheritsList.split(','); + let icon = getIconFromTheme(defaultTheme, iconName, size, context, scale); + + if (icon !== null) { + return icon; + } + + // in case the icon was not found in the theme, we search the inherited themes + for (let key of inherits) { + let inheritsTheme = getIconTheme(inherits[key]); + icon = getIconFromTheme(inheritsTheme, iconName, size, context); if (icon !== null) { return icon; } - - // in case the icon was not found in the theme, we search the inherited themes - for (let key of inherits) { - let inheritsTheme = getIconTheme(inherits[key]); - icon = getIconFromTheme(inheritsTheme, iconName, size, context); - if (icon !== null) { - return icon; - } - } } - return null; }