<commit_before>import {
  SETTINGS_MENU_TOGGLE,
  SWAP_STOCK_AND_LOOT_LISTS,
  INSPECT_ITEM,
  INSPECT_CLOSE,
  CONFIRM_DELETE_FAVORITE,
  CANCEL_DELETE_FAVORITE,
  DELETE_FAVORITE,
  INVENTORY_BUSY,
  INVENTORY_BUSY_DONE,
} from '../actions'

import {
  TOGGLE_SHOW_EMPTY_STOCK,
  TOGGLE_FAVORITE_ROUTES,
  TOGGLE_SHORTEST_ROUTES,
  TOGGLE_SIDE_FLEET,
  TOGGLE_SIDE_INVENTORY,
  TOGGLE_SIDE_NAVIGATION,
  PROFILE_SAVE_START,
  PROFILE_SAVE_END,
  PROFILE_LOAD_START,
  PROFILE_LOAD_END,
  SKIP_ORIGINS_HISTORY,
} from '../actions/layout'

import {
  GPS_BUSY,
  GPS_BUSY_DONE,
} from '../actions/gps'

const STOCK_POS_LEFT = 'left'
const STOCK_POS_RIGHT = 'right'

export const initialState = {
  profileSaving: false,
  profileLoading: false,
  gpsBusy: false,
  contentLayout: 'vertical', // 'vertical', 'side-to-side', 'tabs'
  stockListPosition: STOCK_POS_LEFT,
  settingsMenuOpen: false,
  showEmptyStock: false,
  showInfoDialog: false,
  showConfirmDeleteFavoritesDialog: false,
  showFavoriteRoutes: true,
  showShortestRoutes: true,
  fleetVisibility: true,
  inventoryVisibility: false,
  navigationVisibility: false,
  skipOriginsHistory: 0,

  primaryColor: 'rgb(245, 0, 87)',
}

const toggleSettingsMenu = state => {
  const settingsMenuOpen = !state.settingsMenuOpen
  return Object.assign({}, state, {settingsMenuOpen})
}

const toggleShowEmptyStock = state => {
  const showEmptyStock = !state.showEmptyStock
  return Object.assign({}, state, {showEmptyStock})
}

const toggleFavoriteRoutes = state => {
  const showFavoriteRoutes = !state.showFavoriteRoutes
  return Object.assign({}, state, {showFavoriteRoutes})
}

const swapLists = state => {
  const stockListPosition = (STOCK_POS_LEFT === state.stockListPosition) ? STOCK_POS_RIGHT : STOCK_POS_LEFT
  return Object.assign({}, state, {stockListPosition})
}

const showDeleteFavoriteDialog = (state, system) => {
  const showConfirmDeleteFromFavoritesDialog = system.id
  return Object.assign({}, state, {showConfirmDeleteFavoritesDialog})
}

const closeDeleteFavoriteDialog = state => {
  const showConfirmDeleteFavoritesDialog = false
  return Object.assign({}, state, {showConfirmDeleteFavoritesDialog})
}

const toggleShortestRoutes = state => {
  const showShortestRoutes = !state.showShortestRoutes
  return Object.assign({}, state, { showShortestRoutes })
}

const toggleFleetVisibility = state => {
  const fleetVisibility = !state.fleetVisibility
  return Object.assign({}, state, { fleetVisibility })
}

const toggleInventoryVisibility = state => {
  const inventoryVisibility = !state.inventoryVisibility
  return Object.assign({}, state, { inventoryVisibility })
}

const toggleNavigationVisibility = state => {
  const navigationVisibility = !state.navigationVisibility
  return Object.assign({}, state, { navigationVisibility })<commit_msg>layout reducer now saves and loads from localStorage<commit_after>import {
  SETTINGS_MENU_TOGGLE,
  SWAP_STOCK_AND_LOOT_LISTS,
  INSPECT_ITEM,
  INSPECT_CLOSE,
  CONFIRM_DELETE_FAVORITE,
  CANCEL_DELETE_FAVORITE,
  DELETE_FAVORITE,
  INVENTORY_BUSY,
  INVENTORY_BUSY_DONE,
} from '../actions'

import {
  TOGGLE_SHOW_EMPTY_STOCK,
  TOGGLE_FAVORITE_ROUTES,
  TOGGLE_SHORTEST_ROUTES,
  TOGGLE_SIDE_FLEET,
  TOGGLE_SIDE_INVENTORY,
  TOGGLE_SIDE_NAVIGATION,
  PROFILE_SAVE_START,
  PROFILE_SAVE_END,
  PROFILE_LOAD_START,
  PROFILE_LOAD_END,
  SKIP_ORIGINS_HISTORY,
} from '../actions/layout'

import {
  GPS_BUSY,
  GPS_BUSY_DONE,
} from '../actions/gps'

const STOCK_POS_LEFT = 'left'
const STOCK_POS_RIGHT = 'right'

const config = {
  save: (key, value) => localStorage.setItem(key, value),
  load: (key, defaultValue) => {
    const value = localStorage.getItem(key)

    return "true" === value ? true
    : "false" === value ? false
    : null === value ? defaultValue
    : value
  }
}

export const initialState = {
  profileSaving: false,
  profileLoading: false,
  gpsBusy: false,
  contentLayout: 'vertical', // 'vertical', 'side-to-side', 'tabs'
  stockListPosition: STOCK_POS_LEFT,
  settingsMenuOpen: false,
  showEmptyStock: false,
  showInfoDialog: false,
  showConfirmDeleteFavoritesDialog: false,
  showFavoriteRoutes: config.load('showFavoriteRoutes', true),
  showShortestRoutes: config.load('showShortestRoutes', true),
  fleetVisibility: config.load('fleetVisibility', true),
  inventoryVisibility: config.load('inventoryVisibility', false),
  navigationVisibility: config.load('navigationVisibility', false),
  skipOriginsHistory: 0,

  primaryColor: 'rgb(245, 0, 87)',
}

const toggleSettingsMenu = state => {
  const settingsMenuOpen = !state.settingsMenuOpen
  return Object.assign({}, state, {settingsMenuOpen})
}

const toggleShowEmptyStock = state => {
  const showEmptyStock = !state.showEmptyStock
  return Object.assign({}, state, {showEmptyStock})
}

const toggleFavoriteRoutes = state => {
  const showFavoriteRoutes = !state.showFavoriteRoutes
  config.save('showFavoriteRoutes', showFavoriteRoutes)
  return Object.assign({}, state, {showFavoriteRoutes})
}

const swapLists = state => {
  const stockListPosition = (STOCK_POS_LEFT === state.stockListPosition) ? STOCK_POS_RIGHT : STOCK_POS_LEFT
  return Object.assign({}, state, {stockListPosition})
}

const showDeleteFavoriteDialog = (state, system) => {
  const showConfirmDeleteFromFavoritesDialog = system.id
  return Object.assign({}, state, {showConfirmDeleteFavoritesDialog})
}

const closeDeleteFavoriteDialog = state => {
  const showConfirmDeleteFavoritesDialog = false
  return Object.assign({}, state, {showConfirmDeleteFavoritesDialog})
}

const toggleShortestRoutes = state => {
  const showShortestRoutes = !state.showShortestRoutes
  config.save('showShortestRoutes', showShortestRoutes)
  return Object.assign({}, state, { showShortestRoutes })
}

const toggleFleetVisibility = state => {
  const fleetVisibility = !state.fleetVisibility
  config.save('fleetVisibility', fleetVisibility)
  return Object.assign({}, state, { fleetVisibility })
}

const toggleInventoryVisibility = state => {
  const inventoryVisibility = !state.inventoryVisibility
  config.save('inventoryVisibility', inventoryVisibility)
  return Object.assign({}, state, { inventoryVisibility })
}

const toggleNavigationVisibility = state => {
  const navigationVisibility = !state.navigationVisibility
  config.save('navigationVisibility', navigationVisibility)
  return Object.assign({}, state, { navigationVisibility })
{'fraction_non_alphanumeric': 0.10484499143168718, 'fraction_numerical': 0.0021810250817884407, 'mean_word_length': 5.772151898734177, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 25, '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': '6680821', 'n_tokens_mistral': 2142, 'n_tokens_neox': 2097, 'n_words': 408}