<commit_before>// @flow
import React, { Component } from 'react';
import {
  Image,
  LayoutAnimation,
  PixelRatio,
  ScrollView,
  StyleSheet,
  Text,
  TouchableOpacity,
  View,
} from 'react-native';
import MapView from 'react-native-maps';

import ListTitle from '../../components/ListTitle';
import Navbar from '../../components/Navbar';
import Scene from '../../components/Scene';

import { list as organiserList } from '../../data/organisers';
import theme from '../../theme';
import { attemptToOpenUrl } from '../../utils';

import CodeOfConduct from './components/CodeOfConduct';
import Organiser from './components/Organiser';

// Santa Clara, California
const mapRegion = {
  latitude: 37.391084,
  longitude: -121.9746,
  latitudeDelta: 0.01,
  longitudeDelta: 0.01,
};

export default class Info extends Component {
  props: {
    navigator: Object,
    organisers: typeof organiserList,
  };

  state = {
    modalIsOpen: false,
  };

  static defaultProps = {
    organisers: organiserList,
  };

  _marker: any;

  componentDidMount() {
    setTimeout(this._marker.showCallout, 1000);
  }

  toggleModal = () => {
    LayoutAnimation.easeInEaseOut();
    this.setState({ modalIsOpen: !this.state.modalIsOpen });
  };

  openMap() {
    const latlon = `${mapRegion.latitude},${mapRegion.longitude}`;
    const query = encodeURI('Santa Clara Marriott');
    const url = `maps://maps.apple.com/?ll=${latlon}&q=${query}`;<commit_msg>On slow devices sometimes this._marker is undefined after a second. Just keep trying a second later rather than crashing the app.<commit_after>// @flow
import React, { Component } from 'react';
import {
  Image,
  LayoutAnimation,
  PixelRatio,
  ScrollView,
  StyleSheet,
  Text,
  TouchableOpacity,
  View,
} from 'react-native';
import MapView from 'react-native-maps';

import ListTitle from '../../components/ListTitle';
import Navbar from '../../components/Navbar';
import Scene from '../../components/Scene';

import { list as organiserList } from '../../data/organisers';
import theme from '../../theme';
import { attemptToOpenUrl } from '../../utils';

import CodeOfConduct from './components/CodeOfConduct';
import Organiser from './components/Organiser';

// Santa Clara, California
const mapRegion = {
  latitude: 37.391084,
  longitude: -121.9746,
  latitudeDelta: 0.01,
  longitudeDelta: 0.01,
};

export default class Info extends Component {
  props: {
    navigator: Object,
    organisers: typeof organiserList,
  };

  state = {
    modalIsOpen: false,
  };

  static defaultProps = {
    organisers: organiserList,
  };

  _marker: any;

  componentDidMount() {
    // Sometimes it takes more than a second for the map to load, so in those cases it's best to
    // just keep trying with an exponential* back off. (* exponential: e to the power of 0) ;-)
    const tryToShowCallout = () => {
      if (this._marker) {
        this._marker.showCallout();
      } else {
        setTimeout(tryToShowCallout, 1000);
      }
    };

    tryToShowCallout();
  }

  toggleModal = () => {
    LayoutAnimation.easeInEaseOut();
    this.setState({ modalIsOpen: !this.state.modalIsOpen });
  };

  openMap() {
    const latlon = `${mapRegion.latitude},${mapRegion.longitude}`;
    const query = encodeURI('Santa Clara Marriott');
    const url = `maps://maps.apple.com/?ll=${latlon}&q=${query}`;
{'fraction_non_alphanumeric': 0.144136078782453, 'fraction_numerical': 0.01521933751119069, 'mean_word_length': 3.4105263157894736, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, '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': '4086279', 'n_tokens_mistral': 1071, 'n_tokens_neox': 1027, 'n_words': 280}