Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Adds stop all sounds playing" #49

Merged
merged 1 commit into from
May 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/containers/Sounds/MapCircleContainer.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import MapCircle from 'components/Sounds/MapCircle';
import { playAudio, stopAudio } from '../Audio/actions';
Expand Down
12 changes: 0 additions & 12 deletions src/containers/Sounds/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import { displaySystemMessage } from '../MessagesBox/actions';
import { submitQuery, reshapeReceivedSounds } from '../Search/utils';
import { setSpaceAsCenter, computeSpaceClusters } from '../Spaces/actions';
import { getTrainedTsne, computePointsPositionInSolution } from './utils';
import { stopAudio } from '../Audio/actions';
import { getPropertyArrayOfDictionaryEntries } from '../../utils/objectUtils';

export const FETCH_SOUNDS_REQUEST = 'FETCH_SOUNDS_REQUEST';
export const FETCH_SOUNDS_SUCCESS = 'FETCH_SOUNDS_SUCCESS';
Expand Down Expand Up @@ -47,16 +45,6 @@ export const deselectAllSounds = () => (dispatch, getStore) => {
let clearTimeoutId;
let progress = 0;

// TODO: buggy -> when playing many sounds by hover, stop does not work on all sounds
export const stopAllSoundsPlaying = () => (dispatch, getStore) => {
const playingSourceNodes = getStore().audio.playingSourceNodes;
// Object.keys(playingSourceNodes).forEach(
// idx => dispatch(stopAudio(Number(idx), playingSourceNodes[idx].soundID))
// );
const playingSounds = getPropertyArrayOfDictionaryEntries(playingSourceNodes, 'soundID');
playingSounds.forEach(soundID => dispatch(stopAudio(soundID)));
};

const updateProgress = (sounds, stepIteration) => (dispatch) => {
const computedProgress = (stepIteration + 1) / MAX_TSNE_ITERATIONS;
const computedProgressPercentage = parseInt(100 * computedProgress, 10);
Expand Down
8 changes: 0 additions & 8 deletions src/utils/objectUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,3 @@ export const pureDeleteObjectKey = (obj, property, leaveKey = false) => {
return Object.assign(goodObj, {
[badKey]: pureDeleteObjectKey(obj[badKey], remainingBadKeys, leaveKey) });
};

export const getPropertyArrayOfDictionaryEntries = (dictionary, propertyName) => {
const valueArray = [];
Object.keys(dictionary).forEach(
key => valueArray.push(readObjectPropertyByPropertyAbsName(dictionary[key], propertyName))
);
return valueArray;
};
10 changes: 0 additions & 10 deletions src/utils/objectUtils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,6 @@ describe('object utils', () => {
expect(utils.readObjectPropertyByPropertyAbsName(x, 'a.1.b')).toEqual(3);
});
});
describe('getPropertyArrayOfDictionaryEntries', () => {
it('correctly returns the array of property values of an dictionary like object', () => {
const x = {
0: { a: [22, { b: 3 }] },
1: { a: [22, { b: 2 }] },
};
expect(utils.getPropertyArrayOfDictionaryEntries(x, 'a[1].b')).toEqual([3, 2]);
expect(utils.getPropertyArrayOfDictionaryEntries(x, 'a.1.b')).toEqual([3, 2]);
});
});
describe('pureDeleteObjectKey', () => {
const testObj = { x: 1, y: { a: 4, b: [3, 4, 5], c: { d: 1 } } };
deepFreeze(testObj);
Expand Down