From f91c52cdf76a9e8886630cd0d546ad2348663913 Mon Sep 17 00:00:00 2001 From: Laurent Cozic Date: Wed, 7 Feb 2018 19:51:58 +0000 Subject: [PATCH] Mobile: Update time when app is activated --- ReactNativeClient/root.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/ReactNativeClient/root.js b/ReactNativeClient/root.js index d396f9e94c..66cc20e2da 100644 --- a/ReactNativeClient/root.js +++ b/ReactNativeClient/root.js @@ -1,5 +1,5 @@ const React = require('react'); const Component = React.Component; -const { Keyboard, NativeModules, BackHandler } = require('react-native'); +const { AppState, Keyboard, NativeModules, BackHandler } = require('react-native'); const { SafeAreaView } = require('react-navigation'); const { connect, Provider } = require('react-redux'); const { BackButtonService } = require('lib/services/back-button.js'); @@ -469,6 +469,10 @@ class AppComponent extends React.Component { this.backButtonHandler_ = () => { return this.backButtonHandler(); } + + this.onAppStateChange_ = () => { + PoorManIntervals.update(); + } } async componentDidMount() { @@ -493,6 +497,12 @@ class AppComponent extends React.Component { const notification = await Alarm.makeNotification(alarm); this.dropdownAlert_.alertWithType('info', notification.title, notification.body ? notification.body : ''); }); + + AppState.addEventListener('change', this.onAppStateChange_); + } + + componentWillUnmount() { + AppState.removeEventListener('change', this.onAppStateChange_); } async backButtonHandler() {