From 7e889dd509e106a3bfbc76ac4e64e5ba4ff3dfb7 Mon Sep 17 00:00:00 2001 From: Mike Date: Tue, 26 Jul 2016 11:46:23 -0600 Subject: [PATCH] Add a slight timeout to update the fontSmoothing pref (#407) This seems like a bug with chrome/electron where the devicePixelRatio value doesn't update right away. It's probably in the event loop, so adding a short timeout should solve this problem. --- lib/actions/ui.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/lib/actions/ui.js b/lib/actions/ui.js index ee4cfd72..39056bcf 100644 --- a/lib/actions/ui.js +++ b/lib/actions/ui.js @@ -60,14 +60,18 @@ export function resetFontSize () { } export function setFontSmoothing () { - const devicePixelRatio = window.devicePixelRatio; - const fontSmoothing = devicePixelRatio < 2 - ? 'subpixel-antialiased' - : 'antialiased'; + return (dispatch) => { + setTimeout(() => { + const devicePixelRatio = window.devicePixelRatio; + const fontSmoothing = devicePixelRatio < 2 + ? 'subpixel-antialiased' + : 'antialiased'; - return { - type: UI_FONT_SMOOTHING_SET, - fontSmoothing + dispatch({ + type: UI_FONT_SMOOTHING_SET, + fontSmoothing + }); + }, 100); }; }