Skip to content

Commit

Permalink
Encoding playlist during AddTracksToPlaylist, patch missing connect; f…
Browse files Browse the repository at this point in the history
…ixes #684
  • Loading branch information
jaedb committed Feb 7, 2021
1 parent c2b1fdf commit 5b62f76
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
4 changes: 3 additions & 1 deletion src/js/components/PlaylistGrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,10 @@ class PlaylistGrid extends React.Component {
}
}

const mapStateToProps = (state) => state;

const mapDispatchToProps = (dispatch) => ({
uiActions: bindActionCreators(uiActions, dispatch),
});

export default connect(mapDispatchToProps)(PlaylistGrid);
export default connect(mapStateToProps, mapDispatchToProps)(PlaylistGrid);
3 changes: 2 additions & 1 deletion src/js/services/core/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import { uriSource } from '../../util/helpers';
const spotifyActions = require('../../services/spotify/actions');
const mopidyActions = require('../../services/mopidy/actions');

export function handleException(message, data = {}, description = null, show_notification = true) {
export function handleException(message = '', data = {}, description = null, show_notification = true) {
console.debug({ message, data })
if (!message) {
if (data.message) {
message = data.message;
Expand Down
8 changes: 7 additions & 1 deletion src/js/services/mopidy/middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import ReactGA from 'react-ga';
import Mopidy from 'mopidy';
import { sha256 } from 'js-sha256';
import { sampleSize, compact, chunk } from 'lodash';
import { i18n } from '../../locale';
import { i18n, I18n } from '../../locale';
import {
generateGuid,
uriSource,
Expand Down Expand Up @@ -1217,6 +1217,12 @@ const MopidyMiddleware = (function () {
case 'MOPIDY_ADD_PLAYLIST_TRACKS':
request(store, 'playlists.lookup', { uri: action.key })
.then((response) => {
if (!response) {
store.dispatch(coreActions.handleException(
i18n('errors.uri_not_found', { uri: action.key }),
));
return;
}
const tracks = action.tracks_uris.map((uri) => ({ __model__: 'Track', uri }));
const playlist = { ...response };
if (playlist.tracks) {
Expand Down
6 changes: 3 additions & 3 deletions src/js/views/modals/AddToPlaylist.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import * as coreActions from '../../services/core/actions';
import * as uiActions from '../../services/ui/actions';
import * as mopidyActions from '../../services/mopidy/actions';
import * as spotifyActions from '../../services/spotify/actions';
import { sourceIcon, decodeMopidyUri } from '../../util/helpers';
import { sourceIcon } from '../../util/helpers';
import { sortItems } from '../../util/arrays';
import { I18n, i18n } from '../../locale';
import { collate } from '../../util/format';
import { collate, decodeUri } from '../../util/format';
import { makeProcessProgressSelector } from '../../util/selectors';

const processKeys = [
Expand Down Expand Up @@ -57,7 +57,7 @@ class AddToPlaylist extends React.Component {
},
uris,
} = this.props;
const encodedUris = uris.map((uri) => decodeMopidyUri(uri));
const encodedUris = uris.map((uri) => decodeUri(uri));
addTracksToPlaylist(playlist_uri, encodedUris);
window.history.back();
}
Expand Down

0 comments on commit 5b62f76

Please sign in to comment.