Adding new playlist to library, fixes #733
This commit is contained in:
@ -1340,7 +1340,7 @@ class ContextMenu extends React.Component {
|
||||
}
|
||||
}
|
||||
|
||||
const librarySelector = makeLibrarySelector('playlists');
|
||||
const librarySelector = makeLibrarySelector('playlists', false);
|
||||
const providersSelector = makeProvidersSelector('playlists');
|
||||
const processProgressSelector = makeProcessProgressSelector(processKeys);
|
||||
|
||||
|
||||
@ -29,6 +29,7 @@ import {
|
||||
sortItems,
|
||||
indexToArray,
|
||||
} from '../../util/arrays';
|
||||
import { getProvider } from '../../util/selectors';
|
||||
|
||||
const mopidyActions = require('./actions.js');
|
||||
const coreActions = require('../core/actions.js');
|
||||
@ -1357,7 +1358,10 @@ const MopidyMiddleware = (function () {
|
||||
store.dispatch(uiActions.createNotification({
|
||||
content: i18n('actions.created', { name: i18n('playlist.title') }),
|
||||
}));
|
||||
store.dispatch(coreActions.addToLibrary('mopidy:library:playlists', playlist));
|
||||
store.dispatch(coreActions.addToLibrary(
|
||||
getProvider('playlists', 'm3u:')?.uri,
|
||||
playlist,
|
||||
));
|
||||
});
|
||||
break;
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@ import {
|
||||
injectSortId,
|
||||
} from '../../util/format';
|
||||
import URILink from '../../components/URILink';
|
||||
import { getItem } from '../../util/selectors';
|
||||
import { getItem, providers, getProvider } from '../../util/selectors';
|
||||
|
||||
const coreActions = require('../core/actions');
|
||||
const uiActions = require('../ui/actions');
|
||||
@ -1171,10 +1171,10 @@ export function createPlaylist(name, description, is_public, is_collaborative) {
|
||||
tracks: [],
|
||||
}));
|
||||
|
||||
dispatch({
|
||||
type: 'LIBRARY_PLAYLISTS_LOADED',
|
||||
uris: [response.uri],
|
||||
});
|
||||
dispatch(coreActions.addToLibrary(
|
||||
getProvider('playlists', 'spotify:')?.uri,
|
||||
response,
|
||||
));
|
||||
|
||||
dispatch(uiActions.createNotification({ content: 'Created playlist' }));
|
||||
},
|
||||
|
||||
@ -52,10 +52,10 @@ const queueHistorySelector = createSelector(
|
||||
);
|
||||
|
||||
const getLibrarySource = (state, name) => state.ui[`library_${name}_source`] || 'all';
|
||||
const makeLibrarySelector = (name) => createSelector(
|
||||
const makeLibrarySelector = (name, filtered = true) => createSelector(
|
||||
[getLibraries, getItems, getLibrarySource],
|
||||
(libraries, items, source) => {
|
||||
const selectedLibraries = source === 'all'
|
||||
const selectedLibraries = !filtered || source === 'all'
|
||||
? indexToArray(libraries).filter((l) => l.type === name)
|
||||
: indexToArray(libraries, [source]);
|
||||
|
||||
@ -183,6 +183,7 @@ const providers = {
|
||||
},
|
||||
],
|
||||
};
|
||||
const getProvider = (type, scheme) => providers[type]?.find((p) => p.scheme === scheme);
|
||||
const getUriSchemes = (state) => state.mopidy.uri_schemes || [];
|
||||
const makeProvidersSelector = (context) => createSelector(
|
||||
[getUriSchemes],
|
||||
@ -206,4 +207,5 @@ export {
|
||||
makeProcessProgressSelector,
|
||||
queueHistorySelector,
|
||||
makeProvidersSelector,
|
||||
getProvider,
|
||||
};
|
||||
|
||||
@ -120,7 +120,7 @@ class AddToPlaylist extends React.Component {
|
||||
}
|
||||
}
|
||||
|
||||
const librarySelector = makeLibrarySelector('playlists');
|
||||
const librarySelector = makeLibrarySelector('playlists', false);
|
||||
const processProgressSelector = makeProcessProgressSelector(processKeys);
|
||||
const providersSelector = makeProvidersSelector('playlists');
|
||||
const mapStateToProps = (state, ownProps) => {
|
||||
|
||||
Reference in New Issue
Block a user