From 2df6f31e1a1326569c5f9004ca73b253282c93d3 Mon Sep 17 00:00:00 2001 From: stevepodell Date: Thu, 11 Jan 2018 14:18:40 -0800 Subject: [PATCH 1/3] Two navigation fixes. If you are not authenticated and you click on the avatar-generic icon, you should bring up the AccountMenuModal menu. If you are not authenticated, do not show the "Your Account" option on the AccountMenuModal menu. --- src/js/actions/TabActions.js | 49 ++++++++++++++++++++++++ src/js/scenes/App.js | 19 +-------- src/js/scenes/SignIn/AccountMenuModal.js | 10 +++-- 3 files changed, 57 insertions(+), 21 deletions(-) diff --git a/src/js/actions/TabActions.js b/src/js/actions/TabActions.js index 7bbb105..040a618 100644 --- a/src/js/actions/TabActions.js +++ b/src/js/actions/TabActions.js @@ -1,7 +1,56 @@ +import { Actions } from 'react-native-router-flux'; import Dispatcher from "../dispatcher/Dispatcher"; +import RouteConst from "../scenes/RouteConst" export default class TabActions { + static tabPressed (scene) { + /* + January 2018, Observed locations of the data we need, with + "react-native": "0.47.2" + "react-native-router-flux": "4.0.0-beta.24" + "flux": "3.1.3" + "react-router": "4.2.0" + "react-router-native": "4.2.0" + Observed locations of the data we need... + current key can be at + scene.route.key + scene.scene.route.key + previous key can be at + scene.previousScene.key + scene.scene.previousScene.key + */ + + let scene_local; + if (scene.route) { + scene_local = scene; + } else if (scene.scene.route) { + scene_local = scene.scene; + } else { + console.log("ERROR: tabPressed was unable to find a sceneLocal"); + return; + } + + let sceneLocal = scene_local; + let currentKey = sceneLocal.route.key; + let previousKey; + if (sceneLocal.previousScene) { + previousKey = sceneLocal.previousScene.key; + } else if (scene.previousScene) { + previousKey = scene.previousScene.key; + } else { + console.log("ERROR: tabPressed was unable to find a sceneLocalPrevious"); + return; + } + console.log('TabActions.TabPress, currentKey = ' + currentKey + ', previousKey = ', previousKey + ','); + // if on the signin tab, and you click the sign in tab. A special case. + if (previousKey === RouteConst.KEY_SIGNIN_1 && previousKey === currentKey ) { + TabActions.tabStateChanged(); + } + + return Actions[scene_local.route.key].call(); + } + static tabStateChanged () { console.log('TabActions, received tabStateChanged'); Dispatcher.dispatch({ diff --git a/src/js/scenes/App.js b/src/js/scenes/App.js index f2f902c..b7a9ff7 100644 --- a/src/js/scenes/App.js +++ b/src/js/scenes/App.js @@ -41,24 +41,7 @@ export default class App extends Component { } onTabPress(scene) { - // console.log('App.js onTabPress, scene.previousScene.key = ' + scene.previousScene.key + - // ', scene.route.key = ', scene.scene.route.key); - - let scene_local; - if (scene.route) { - scene_local = scene; - } else if (scene.scene.route) { - scene_local = scene.scene; - } else { - return; - } - - // if on the signin tab, and you click the sign in tab. A special case. - if (scene_local.previousScene && scene_local.previousScene.key === RouteConst.KEY_SIGNIN_1 && scene_local.previousScene.key === scene_local.route.key ) { - TabActions.tabStateChanged(); - } - - return Actions[scene_local.route.key].call(); + return TabActions.tabPressed(scene); } render() { diff --git a/src/js/scenes/SignIn/AccountMenuModal.js b/src/js/scenes/SignIn/AccountMenuModal.js index b1c2366..87fd168 100644 --- a/src/js/scenes/SignIn/AccountMenuModal.js +++ b/src/js/scenes/SignIn/AccountMenuModal.js @@ -11,6 +11,7 @@ import Modal from 'react-native-modal' import { Actions } from 'react-native-router-flux'; import Icon from "react-native-vector-icons/FontAwesome"; +import CookieStore from "../../stores/CookieStore"; import styles from "../../stylesheets/components/baseStyles"; import styleConst from "../../stylesheets/styleConst"; import VoterSessionActions from "../../actions/VoterSessionActions"; @@ -173,9 +174,12 @@ export default class AccountMenu extends Component { Our Promise: We'll never sell your email. {/*Your Voter Guide (Twitter)*/} {/*Your Voter Guide (Facebook)*/} - - Your Account - + + {isAuthenticated && + + Your Account + + } {! isAuthenticated && Sign In From cf140085ebe98f6ea996affffb7e3292dbbfb4f2 Mon Sep 17 00:00:00 2001 From: stevepodell Date: Thu, 11 Jan 2018 16:24:19 -0800 Subject: [PATCH 2/3] Two navigation fixes. If you are not authenticated and you click on the avatar-generic icon, you should bring up the AccountMenuModal menu. If you are not authenticated, do not show the "Your Account" option on the AccountMenuModal menu. Added a note to DEBUGGING_TOOLS.md to tell how to get the debug menu to appear on a tethered iphone. Made a fix to Cookie store to get the URL parser to work when untethered on an iPhone. --- docs/working/DEBUGGING_TOOLS_IOS.md | 3 ++- src/js/stores/CookieStore.js | 13 ++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/working/DEBUGGING_TOOLS_IOS.md b/docs/working/DEBUGGING_TOOLS_IOS.md index 2ba43e0..39193a9 100644 --- a/docs/working/DEBUGGING_TOOLS_IOS.md +++ b/docs/working/DEBUGGING_TOOLS_IOS.md @@ -2,7 +2,8 @@ [Go back to Working with react-native-router-flux](WORKING_WITH_REACT_NATIVE_ROUTER_FLUX.md) -In the iOS simulator press Command+D to get the simulator debugger window (Command+M for Android) +In the iOS simulator press Command+D to get the simulator debug menu (Command+M for Android). On a physical iPhone +attached via a USB cord, shake the device to bring up the debug menu. alt text diff --git a/src/js/stores/CookieStore.js b/src/js/stores/CookieStore.js index 6783ab0..d47584a 100644 --- a/src/js/stores/CookieStore.js +++ b/src/js/stores/CookieStore.js @@ -1,8 +1,9 @@ import { Platform } from 'react-native'; import _ from "lodash"; import CookieManager from 'react-native-cookies'; -import { default as webAppConfig } from '../config'; import Promise from 'bluebird'; +import url from 'url'; +import { default as webAppConfig } from '../config'; const logging = require("../utils/logging"); // A wrapper class for react-native-cookie @@ -19,9 +20,7 @@ class CookieStore { directed to a specific route in the webapp that reassembles the url, uses the cookie to join the sessions. */ constructor() { - let steve = webAppConfig.WE_VOTE_SERVER_ROOT_URL; - console.log("steve steve steve " , steve); - let host = new URL(webAppConfig.WE_VOTE_SERVER_ROOT_URL).hostname; + let host = url.parse(webAppConfig.WE_VOTE_SERVER_ROOT_URL).host; this.state = { urlString: webAppConfig.WE_VOTE_SERVER_ROOT_URL, current_voter_device_id: '', @@ -39,12 +38,12 @@ class CookieStore { https://wevote.us/more/jump?jump_path=%2Fmore%2Ftools&voter_device_id=G834YIXbfsVB0z */ getJumpURLWithCookie(inUrlString) { - let url = new URL(inUrlString); + let urlObject = url.parse(inUrlString); let urlSearch = ''; if(urlSearch.length > 1) { - urlSearch = '&' + url.search.substr(1); // '?key=value' to '&key=value' + urlSearch = '&' + urlObject.search.substr(1); // '?key=value' to '&key=value' } - let outUrlString = url.protocol + '//' + url.host + '/more/jump?jump_path=' + encodeURIComponent(url.pathname) + + let outUrlString = urlObject.protocol + '//' + urlObject.host + '/more/jump?jump_path=' + encodeURIComponent(urlObject.pathname) + '&voter_device_id=' + this.state.current_voter_device_id + urlSearch; console.log("getJumpURLWithCookie transformed '" + inUrlString + "' to '" + outUrlString + "'"); return outUrlString; From fec05a8bd0a5f757267c2f4b14acd1968de0b14e Mon Sep 17 00:00:00 2001 From: stevepodell Date: Thu, 11 Jan 2018 16:51:38 -0800 Subject: [PATCH 3/3] Two navigation fixes. If you are not authenticated and you click on the avatar-generic icon, you should bring up the AccountMenuModal menu. If you are not authenticated, do not show the "Your Account" option on the AccountMenuModal menu. Added a note to DEBUGGING_TOOLS.md to tell how to get the debug menu to appear on a tethered iphone. Made a fix to Cookie store to get the URL parser to work when untethered on an iPhone. Changed signed-in to fb/twitter buttons to render correctly on iPhone 7p --- src/js/scenes/SignIn/SignIn.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/js/scenes/SignIn/SignIn.js b/src/js/scenes/SignIn/SignIn.js index 0913a48..8244674 100644 --- a/src/js/scenes/SignIn/SignIn.js +++ b/src/js/scenes/SignIn/SignIn.js @@ -301,7 +301,7 @@ export default class SignIn extends Component { } {isAuthenticated && Currently Signed In} {isAuthenticatedTwitter && - + @@ -311,7 +311,7 @@ export default class SignIn extends Component { } {isAuthenticatedFacebook && - +