<commit_before>import React from 'react';
import { StyleSheet, DeviceEventEmitter } from 'react-native';
import Mapbox from 'react-native-mapbox-gl';
import { Actions } from 'react-native-router-flux';
import TaskActions from '../../actions/TaskActions';
import taskStore from '../../stores/TaskStore';

const styles = StyleSheet.create({
  container: {
    flex: 1,
    marginBottom: 45,
  },
});

const mapRef = 'OpenStreetMap';
const ACCESS_TOKEN = '<KEY>'; // eslint-disable-line max-len
const STYLE_URL = 'https://raw.githubusercontent.com/osm2vectortiles/mapbox-gl-styles/master/styles/bright-v9-cdn.json';
const ZOOM_LEVEL = 13;

const Map = React.createClass({
  mixins: [Mapbox.Mixin],

  getInitialState() {
    return {
      annotations: [],
    };
  },

  componentDidMount() {
    DeviceEventEmitter.addListener('onOpenAnnotation', this.onOpenAnnotation);
    navigator.geolocation.getCurrentPosition(this.onPositionChange);
    this.locationWatchId = navigator.geolocation.watchPosition(this.onPositionChange,
      (error) => console.log(error),
      { enableHighAccurracy: true, distanceFilter: 100 });

    taskStore.addChangeListener(this.onTasksUpdate);
  },

  componentWillUnmount() {
    DeviceEventEmitter.removeAllListeners();
    navigator.geolocation.clearWatch(this.locationWatchId);

    taskStore.removeChangeListener(this.onTasksUpdate);
  },

  onPositionChange(position) {
    const latitude = position.coords.latitude;
    const longitude = position.coords.longitude;

    this.setCenterCoordinateZoomLevelAnimated(mapRef, latitude, longitude, ZOOM_LEVEL);
    TaskActions.loadTasks(latitude, longitude);
  },

  onTasksUpdate() {
    this.updateAnnotations();
  },

  onOpenAnnotation(annotation) {
    console.log(annotation);
     // annotation Objekt - Mission übergeben
    if (require('react-native').Platform.OS === 'android') {
      Actions.missionModal(
        { title: annotation.src.title, data: 'Custom data' }
      );
    } else {
      Actions.missionModal(
        { title: annotation.title, data: 'Custom data' }
      );
    }

  },

  // locationWatchId: null,

  updateAnnotations() {
    const annotations = [];

    for (let task of taskStore.getAll()) { // eslint-disable-line prefer-const
      annotations.push({
        id: task.id,
        type: 'point',
        title: task.title,
        subtitle: task.id,
        coordinates: [parseFloat(task.latitude), parseFloat(task.longitude)],
        task,
      });
    }
    this.setState({ annotations });
  },

  render() {
    return (
      <Mapbox
        annotations = { this.state.annotations }
        style = { styles.container }
        direction = { 0 }
        rotateEnabled
        scrollEnabled
        zoomEnabled
        showsUserLocation
        ref = { mapRef }
        accessToken = { ACCESS_TOKEN }
        styleURL = { STYLE_URL }
        logoIsHidden
        //attributionButtonIsHidden
        onOpenAnnotation = { this.onOpenAnnotation }
        userTrackingMode = { this.userTrackingMode.follow }
      />
    );
  },
});

module.exports = Map;
<commit_msg>removed comment<commit_after>import React from 'react';
import { StyleSheet, DeviceEventEmitter } from 'react-native';
import Mapbox from 'react-native-mapbox-gl';
import { Actions } from 'react-native-router-flux';
import TaskActions from '../../actions/TaskActions';
import taskStore from '../../stores/TaskStore';

const styles = StyleSheet.create({
  container: {
    flex: 1,
    marginBottom: 45,
  },
});

const mapRef = 'OpenStreetMap';
const ACCESS_TOKEN = '<KEY>'; // eslint-disable-line max-len
const STYLE_URL = 'https://raw.githubusercontent.com/osm2vectortiles/mapbox-gl-styles/master/styles/bright-v9-cdn.json';
const ZOOM_LEVEL = 13;

const Map = React.createClass({
  mixins: [Mapbox.Mixin],

  getInitialState() {
    return {
      annotations: [],
    };
  },

  componentDidMount() {
    DeviceEventEmitter.addListener('onOpenAnnotation', this.onOpenAnnotation);
    navigator.geolocation.getCurrentPosition(this.onPositionChange);
    this.locationWatchId = navigator.geolocation.watchPosition(this.onPositionChange,
      (error) => console.log(error),
      { enableHighAccurracy: true, distanceFilter: 100 });

    taskStore.addChangeListener(this.onTasksUpdate);
  },

  componentWillUnmount() {
    DeviceEventEmitter.removeAllListeners();
    navigator.geolocation.clearWatch(this.locationWatchId);

    taskStore.removeChangeListener(this.onTasksUpdate);
  },

  onPositionChange(position) {
    const latitude = position.coords.latitude;
    const longitude = position.coords.longitude;

    this.setCenterCoordinateZoomLevelAnimated(mapRef, latitude, longitude, ZOOM_LEVEL);
    TaskActions.loadTasks(latitude, longitude);
  },

  onTasksUpdate() {
    this.updateAnnotations();
  },

  onOpenAnnotation(annotation) {
    console.log(annotation);
     // annotation Objekt - Mission übergeben
    if (require('react-native').Platform.OS === 'android') {
      Actions.missionModal(
        { title: annotation.src.title, data: 'Custom data' }
      );
    } else {
      Actions.missionModal(
        { title: annotation.title, data: 'Custom data' }
      );
    }

  },

  updateAnnotations() {
    const annotations = [];

    for (let task of taskStore.getAll()) { // eslint-disable-line prefer-const
      annotations.push({
        id: task.id,
        type: 'point',
        title: task.title,
        subtitle: task.id,
        coordinates: [parseFloat(task.latitude), parseFloat(task.longitude)],
        task,
      });
    }
    this.setState({ annotations });
  },

  render() {
    return (
      <Mapbox
        annotations = { this.state.annotations }
        style = { styles.container }
        direction = { 0 }
        rotateEnabled
        scrollEnabled
        zoomEnabled
        showsUserLocation
        ref = { mapRef }
        accessToken = { ACCESS_TOKEN }
        styleURL = { STYLE_URL }
        logoIsHidden
        //attributionButtonIsHidden
        onOpenAnnotation = { this.onOpenAnnotation }
        userTrackingMode = { this.userTrackingMode.follow }
      />
    );
  },
});

module.exports = Map;

{'fraction_non_alphanumeric': 0.12441123923988956, 'fraction_numerical': 0.003573168751015105, 'mean_word_length': 3.035386631716907, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 2, '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': '1182769', 'n_tokens_mistral': 1886, 'n_tokens_neox': 1817, 'n_words': 325}