From 4d0af575e51245eedad5da29aab140d897dd5f94 Mon Sep 17 00:00:00 2001 From: Laurent Cozic Date: Mon, 16 Apr 2018 15:15:29 +0200 Subject: [PATCH] Mobile: Resolves #360: Don't crash if theme not set and improved logging. --- ReactNativeClient/lib/components/global-style.js | 5 ++++- ReactNativeClient/root.js | 11 ++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/ReactNativeClient/lib/components/global-style.js b/ReactNativeClient/lib/components/global-style.js index 135898875..6aa1fd725 100644 --- a/ReactNativeClient/lib/components/global-style.js +++ b/ReactNativeClient/lib/components/global-style.js @@ -100,7 +100,10 @@ function addExtraStyles(style) { } function themeStyle(theme) { - if (!theme) throw new Error('Theme not set'); + if (!theme) { + console.warn('Theme not set!! Defaulting to Light theme'); + theme = Setting.THEME_LIGHT; + } if (themeCache_[theme]) return themeCache_[theme]; diff --git a/ReactNativeClient/root.js b/ReactNativeClient/root.js index 64d5caa27..c7954be26 100644 --- a/ReactNativeClient/root.js +++ b/ReactNativeClient/root.js @@ -72,8 +72,17 @@ const EncryptionService = require('lib/services/EncryptionService'); let storeDispatch = function(action) {}; +const logReducerAction = function(action) { + if (['SIDE_MENU_OPEN_PERCENT', 'SYNC_REPORT_UPDATE'].indexOf(action.type) >= 0) return; + + let msg = [action.type]; + if (action.routeName) msg.push(action.routeName); + + reg.logger().info('Reducer action', msg.join(', ')); +} + const generalMiddleware = store => next => async (action) => { - if (['SIDE_MENU_OPEN_PERCENT', 'SYNC_REPORT_UPDATE'].indexOf(action.type) < 0) reg.logger().info('Reducer action', action.type); + logReducerAction(action); PoorManIntervals.update(); // This function needs to be called regularly so put it here const result = next(action);