<commit_before>import fs from 'fs';
import React from 'react';

import PhotoActions from './../actions/photo-actions';

import Tags from './tags';
import Dates from './dates';
import Devices from './devices';

import config from './../config';

var settings;

if (fs.existsSync(config.settings))
  settings = require(config.settings);

class Sidebar extends React.Component {

  constructor(props) {
    super(props);
    console.log(settings);
  }

  clearFilters() {
    PhotoActions.getPhotos();
  }

  filterFlagged() {
    PhotoActions.getFlagged();
  }

  render() {
    var menus = [
      <Dates />,
      <Tags />,
      <Devices />
    ];

    if (settings.hasOwnProperty('menus')) {
      menus = [];

      settings.menus.forEach((menu) => {
        if (menu == 'dates') menus.push(<Dates />);
        else if (menu == 'tags') menus.push(<Tags />);
        else if (menu == 'devices') menus.push(<Devices />);
      });
    }
<commit_msg>Avoid crash when settings is not present<commit_after>import fs from 'fs';
import React from 'react';

import PhotoActions from './../actions/photo-actions';

import Tags from './tags';
import Dates from './dates';
import Devices from './devices';

import config from './../config';

var settings;

if (fs.existsSync(config.settings))
  settings = require(config.settings);

class Sidebar extends React.Component {

  constructor(props) {
    super(props);
    console.log(settings);
  }

  clearFilters() {
    PhotoActions.getPhotos();
  }

  filterFlagged() {
    PhotoActions.getFlagged();
  }

  render() {
    var menus = [
      <Dates />,
      <Tags />,
      <Devices />
    ];

    if (settings && settings.hasOwnProperty('menus')) {
      menus = [];

      settings.menus.forEach((menu) => {
        if (menu == 'dates') menus.push(<Dates />);
        else if (menu == 'tags') menus.push(<Tags />);
        else if (menu == 'devices') menus.push(<Devices />);
      });
    }

{'fraction_non_alphanumeric': 0.1701908200103146, 'fraction_numerical': 0.0, 'mean_word_length': 2.7524177949709863, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 17, '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': '4791617', 'n_tokens_mistral': 620, 'n_tokens_neox': 593, 'n_words': 145}