Skip to content

Commit

Permalink
Merge pull request #290 from backbonelabs/fix-alert-session
Browse files Browse the repository at this point in the history
Stay on Alert scene
  • Loading branch information
kevhuang authored Apr 13, 2017
2 parents ae079f3 + af6abd5 commit d9c9092
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
6 changes: 5 additions & 1 deletion app/components/posture/PostureMonitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,11 @@ class PostureMonitor extends Component {
this.sessionStateListener = SessionControlServiceEvents.addListener('SessionState', event => {
if (event.hasActiveSession) {
// There is currently an active session running on the device, resume session
this.resumeSession();
// only if we are not on the Alert scene
if (this.props.currentRoute.name === routes.postureMonitor.name
&& this.state.sessionState === sessionStates.RUNNING) {
this.resumeSession();
}
} else {
// There is no active session running on the device, invoke statsHandler to show summary
this.statsHandler(event);
Expand Down
13 changes: 11 additions & 2 deletions app/containers/Application.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,17 @@ class Application extends Component {
// There is an active session, check if we're on the PostureMonitor scene
if (this.navigator) {
const routeStack = this.navigator.getCurrentRoutes();
const currentRoute = routeStack[routeStack.length - 1];
if (currentRoute.name !== routes.postureMonitor.name) {
// Stay on the current scene if postureMonitor is still in the stack.
// Only navigate to it when the user's currently not accessing the monitor
let shouldGoToPostureMonitor = true;
for (let i = 0; i < routeStack.length; i++) {
if (routeStack[i].name === routes.postureMonitor.name) {
shouldGoToPostureMonitor = false;
break;
}
}

if (shouldGoToPostureMonitor) {
// Not currently on the PostureMonitor scene
// Navigate to PostureMonitor to resume session using previous session parameters
SensitiveInfo.getItem(storageKeys.SESSION_STATE)
Expand Down

0 comments on commit d9c9092

Please sign in to comment.