diff --git a/c2tc-mobile/App.js b/c2tc-mobile/App.js index 0cf0831..1f53a15 100644 --- a/c2tc-mobile/App.js +++ b/c2tc-mobile/App.js @@ -57,7 +57,6 @@ export default class App extends Component { }); } await this.beginListeningToLocation(); - } componentWillUnmount() { @@ -200,25 +199,28 @@ Navigator = createStackNavigator({ } }); -shouldNotify = async (eventsNearby) => { +shouldNotify = async eventsNearby => { let showCrimes = await AsyncStorage.getItem("crime_tips"); let showHealth = await AsyncStorage.getItem("health_tips"); let showTranspo = await AsyncStorage.getItem("transpo_tips"); let showFinancial = await AsyncStorage.getItem("financial_tips"); - + let showTips = []; eventsNearby.forEach(event => { - if (event.category.toLowerCase() === "crimes" && showCrimes === "true" - || event.category.toLowerCase() === "health" && showHealth === "true" - || event.category.toLowerCase() === "transportation" && showTranspo === "true" - || event.category.toLowerCase() === "financial" && showFinancial === "true") { + if ( + (event.category.toLowerCase() === "crimes" && showCrimes === "true") || + (event.category.toLowerCase() === "health" && showHealth === "true") || + (event.category.toLowerCase() === "transportation" && + showTranspo === "true") || + (event.category.toLowerCase() === "financial" && showFinancial === "true") + ) { showTips.push(event); } }); return showTips; -} +}; function compareEvents(eventA, eventB) { let eventAScore = eventA.upvotes.length - eventA.downvotes.length; @@ -264,7 +266,7 @@ handleNewLocation = async ({ data, error }) => { if (!showTips) { return; } - + const notificationData = createNotificationData(showTips); const schedulingOptions = { time: Date.now() + 1000 }; Notifications.scheduleLocalNotificationAsync( diff --git a/c2tc-mobile/components/TipOverview.js b/c2tc-mobile/components/TipOverview.js index 5e76623..2db7683 100644 --- a/c2tc-mobile/components/TipOverview.js +++ b/c2tc-mobile/components/TipOverview.js @@ -48,7 +48,7 @@ class TipOverview extends React.Component { this.setState({ user: user, - username: user.anon ? "Anonymous" : user.username, + username: this.props.anon ? "Anonymous" : user.username, address: address, verifiedPin: verifiedPin, token: token @@ -69,7 +69,7 @@ class TipOverview extends React.Component { this.setState({ user: user, - username: user.anon ? "Anonymous" : user.username, + username: this.props.anon ? "Anonymous" : user.username, address: address, verifiedPin: verifiedPin, token: token diff --git a/c2tc-mobile/screens/ProfileScreen.js b/c2tc-mobile/screens/ProfileScreen.js index 79e24f1..f2bb73a 100644 --- a/c2tc-mobile/screens/ProfileScreen.js +++ b/c2tc-mobile/screens/ProfileScreen.js @@ -90,11 +90,15 @@ export default class ProfileScreen extends React.Component { }; async onChangeVisibility(anonymousToOthers) { + this.setState({ anonymousToOthers }); let data = { anon: anonymousToOthers }; - await API.updateUser(this.state.user_id, data); + let token = await AsyncStorage.getItem("token"); + if (token) { + await API.updateUser(token, data); + } } render() { @@ -146,6 +150,10 @@ export default class ProfileScreen extends React.Component { Moderator (Verified) )} + + + Email: {this.state.email} + @@ -174,6 +182,7 @@ export default class ProfileScreen extends React.Component { navigation={this.props.navigation} screenType={"view"} editable={true} + anon={this.state.anonymousToOthers} /> ))} Pending Tips @@ -183,6 +192,7 @@ export default class ProfileScreen extends React.Component { tip={tip} navigation={this.props.navigation} screenType={"approved"} + anon={this.state.anonymousToOthers} /> ))} Denied Tips @@ -192,6 +202,7 @@ export default class ProfileScreen extends React.Component { tip={tip} navigation={this.props.navigation} screenType={"denied"} + anon={this.state.anonymousToOthers} /> ))}