<commit_before>import {
  Components,
  registerComponent,
  withCurrentUser,
  getFragment,
  withMessages,
  withEdit
} from 'meteor/vulcan:core';
import React, { Component } from 'react';
import { Localgroups } from '../../lib/index.js';
import Dialog from 'material-ui/Dialog';
import { withRouter } from 'react-router';
import Users from 'meteor/vulcan:users';

class CommunityHome extends Component {
  constructor(props, context) {
    super(props);
    this.state = {
      newGroupFormOpen: false,
      newEventFormOpen: false,
      currentUserLocation: {lat: 37.871853, lng: -122.258423},
    }
  }

  componentDidMount() {
    const currentUser = this.props.currentUser;
    const currentUserLat = currentUser && currentUser.mongoLocation && currentUser.mongoLocation.coordinates[1]
    const currentUserLng = currentUser && currentUser.mongoLocation && currentUser.mongoLocation.coordinates[0]
    if (currentUserLat && currentUserLng) {
      this.setState({
        currentUserLocation: {lat: currentUserLat, lng: currentUserLng}
      })
    } else {
      if (typeof window !== 'undefined' && typeof navigator !== 'undefined' && navigator) {
        navigator.geolocation.getCurrentPosition((position) => {
          const navigatorLat = position.coords.latitude
          const navigatorLng = position.coords.longitude
          this.setState({
            currentUserLocation: {lat: navigatorLat, lng: navigatorLng}
          })
        });
      }
    }
  }

  handleOpenNewGroupForm = () => {
    this.setState({
      newGroupFormOpen: true,
    })
  }

  handleCloseNewGroupForm = () => {
    this.setState({
      newGroupFormOpen: false,
    })<commit_msg>Fix crash on CommunityHome page in Tor browser due to lack of geolocation<commit_after>import {
  Components,
  registerComponent,
  withCurrentUser,
  getFragment,
  withMessages,
  withEdit
} from 'meteor/vulcan:core';
import React, { Component } from 'react';
import { Localgroups } from '../../lib/index.js';
import Dialog from 'material-ui/Dialog';
import { withRouter } from 'react-router';
import Users from 'meteor/vulcan:users';

class CommunityHome extends Component {
  constructor(props, context) {
    super(props);
    this.state = {
      newGroupFormOpen: false,
      newEventFormOpen: false,
      currentUserLocation: {lat: 37.871853, lng: -122.258423},
    }
  }

  componentDidMount() {
    const currentUser = this.props.currentUser;
    const currentUserLat = currentUser && currentUser.mongoLocation && currentUser.mongoLocation.coordinates[1]
    const currentUserLng = currentUser && currentUser.mongoLocation && currentUser.mongoLocation.coordinates[0]
    if (currentUserLat && currentUserLng) {
      this.setState({
        currentUserLocation: {lat: currentUserLat, lng: currentUserLng}
      })
    } else {
      if (typeof window !== 'undefined' && typeof navigator !== 'undefined' && navigator) {
        if(navigator.geolocation) {
          navigator.geolocation.getCurrentPosition((position) => {
            if(position && position.coords) {
              const navigatorLat = position.coords.latitude
              const navigatorLng = position.coords.longitude
              this.setState({
                currentUserLocation: {lat: navigatorLat, lng: navigatorLng}
              })
            }
          });
        }
      }
    }
  }

  handleOpenNewGroupForm = () => {
    this.setState({
      newGroupFormOpen: true,
    })
  }

  handleCloseNewGroupForm = () => {
    this.setState({
      newGroupFormOpen: false,
    })
{'fraction_non_alphanumeric': 0.11423747889701745, 'fraction_numerical': 0.010692177827799663, 'mean_word_length': 3.0260475651189127, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6741549', 'n_tokens_mistral': 1063, 'n_tokens_neox': 1041, 'n_words': 215}