<commit_before>import electron from 'electron';

import store from '../store.js';
import types  from '../constants/action-types';

import ToastsActions from './ToastsActions';

import * as app from '../lib/app';
import Player from '../lib/player';
import utils from '../utils/utils';
import { shuffleTracks } from '../utils/utils-player';

const ipcRenderer = electron.ipcRenderer;

const audioErrors = {
  aborted:  'The video playback was aborted.',
  corrupt:  'The audio playback was aborted due to a corruption problem.',
  notFound: 'The track file could not be found. It may be due to a file move or an unmounted partition.',
  unknown:  'An unknown error occurred.',
};


const playToggle = () => {
  const { paused } = Player.getAudio();
  // TODO (y.solovyov | KeitIG): calling getState is a hack.
  const { queue, playerStatus } = store.getState().player;

  if(playerStatus === 'stop') {
    start();
  } else if (paused && queue.length > 0) {
    play();
  } else {
    pause();
  }
};

const play = () => {
  // TODO (y.solovyov | KeitIG): calling getState is a hack.
  const { queue } = store.getState().player;
  if(queue !== null) {
    Player.play();
    store.dispatch({
      type : types.APP_PLAYER_PLAY,
    });
  }
};

const pause = () => {
  // TODO (y.solovyov | KeitIG): calling getState is a hack.
  const { queue } = store.getState().player;
  if(queue !== null) {
    Player.pause();
    store.dispatch({
      type : types.APP_PLAYER_PAUSE,
    });
  }<commit_msg>Fix play button not working when there is no queue<commit_after>import electron from 'electron';

import store from '../store.js';
import types  from '../constants/action-types';

import ToastsActions from './ToastsActions';

import * as app from '../lib/app';
import Player from '../lib/player';
import utils from '../utils/utils';
import { shuffleTracks } from '../utils/utils-player';

const ipcRenderer = electron.ipcRenderer;

const audioErrors = {
  aborted:  'The video playback was aborted.',
  corrupt:  'The audio playback was aborted due to a corruption problem.',
  notFound: 'The track file could not be found. It may be due to a file move or an unmounted partition.',
  unknown:  'An unknown error occurred.',
};


const playToggle = () => {
  const { paused } = Player.getAudio();
  // TODO (y.solovyov | KeitIG): calling getState is a hack.
  const { queue, playerStatus } = store.getState().player;

  if(playerStatus === 'stop') {
    start(undefined, 'library');
  } else if (paused && queue.length > 0) {
    play();
  } else {
    pause();
  }
};

const play = () => {
  // TODO (y.solovyov | KeitIG): calling getState is a hack.
  const { queue } = store.getState().player;
  if(queue !== null) {
    Player.play();
    store.dispatch({
      type : types.APP_PLAYER_PLAY,
    });
  }
};

const pause = () => {
  // TODO (y.solovyov | KeitIG): calling getState is a hack.
  const { queue } = store.getState().player;
  if(queue !== null) {
    Player.pause();
    store.dispatch({
      type : types.APP_PLAYER_PAUSE,
    });
  }
{'fraction_non_alphanumeric': 0.15336617405582922, 'fraction_numerical': 0.0006568144499178982, 'mean_word_length': 3.1329715061058345, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '4531072', 'n_tokens_mistral': 971, 'n_tokens_neox': 951, 'n_words': 302}