Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

display email on user profile #255

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions c2tc-mobile/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ export default class App extends Component {
});
}
await this.beginListeningToLocation();

}

componentWillUnmount() {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -264,7 +266,7 @@ handleNewLocation = async ({ data, error }) => {
if (!showTips) {
return;
}

const notificationData = createNotificationData(showTips);
const schedulingOptions = { time: Date.now() + 1000 };
Notifications.scheduleLocalNotificationAsync(
Expand Down
4 changes: 2 additions & 2 deletions c2tc-mobile/components/TipOverview.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
13 changes: 12 additions & 1 deletion c2tc-mobile/screens/ProfileScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -146,6 +150,10 @@ export default class ProfileScreen extends React.Component {
<Text style={styles.dividedText}>Moderator (Verified)</Text>
</View>
)}
<View>
<View style={styles.divider} />
<Text style={styles.dividedText}>Email: {this.state.email}</Text>
</View>
<View style={styles.divider} />
<View style={styles.anonView}>
<Text style={[styles.dividedText, styles.anonText]}>
Expand Down Expand Up @@ -174,6 +182,7 @@ export default class ProfileScreen extends React.Component {
navigation={this.props.navigation}
screenType={"view"}
editable={true}
anon={this.state.anonymousToOthers}
/>
))}
<Text style={styles.subheader}> Pending Tips </Text>
Expand All @@ -183,6 +192,7 @@ export default class ProfileScreen extends React.Component {
tip={tip}
navigation={this.props.navigation}
screenType={"approved"}
anon={this.state.anonymousToOthers}
/>
))}
<Text style={styles.subheader}> Denied Tips </Text>
Expand All @@ -192,6 +202,7 @@ export default class ProfileScreen extends React.Component {
tip={tip}
navigation={this.props.navigation}
screenType={"denied"}
anon={this.state.anonymousToOthers}
/>
))}
</View>
Expand Down