Attempting to get stdout from scan

This commit is contained in:
James Barnsley
2020-02-13 16:59:35 +13:00
parent 571c857814
commit 2988f8f4a7
13 changed files with 46 additions and 46 deletions

View File

@ -9,14 +9,14 @@ const spotifyActions = require('../spotify/actions.js');
const lastfmActions = require('../lastfm/actions.js');
const helpers = require('../../helpers.js');
const CoreMiddleware = (function () {
const CoreMiddleware = (function () {
/**
* The actual middleware inteceptor
* */
return (store) => (next) => (action) => {
const { core } = store.getState();
switch (action.type) {
switch (action.type) {
case 'HANDLE_EXCEPTION':
// Construct meaningful message and description
@ -78,7 +78,7 @@ const CoreMiddleware = (function () {
}
if (action.show_notification) {
store.dispatch(uiActions.createNotification({ content: message, type: 'bad', description }));
store.dispatch(uiActions.createNotification({ content: message, level: 'error', description }));
}
console.error(message, description, data);
@ -227,8 +227,8 @@ const CoreMiddleware = (function () {
break;
case 'PLAYLIST_TRACKS_ADDED':
store.dispatch(uiActions.createNotification({ type: 'info', content: `Added ${action.tracks_uris.length} tracks to playlist` }));
switch (helpers.uriSource(action.key)) {
store.dispatch(uiActions.createNotification({ level: 'warning', content: `Added ${action.tracks_uris.length} tracks to playlist` }));
switch (helpers.uriSource(action.key)) {
case 'spotify':
store.dispatch(spotifyActions.getPlaylist(action.key));
break;
@ -603,7 +603,7 @@ const CoreMiddleware = (function () {
var artist = helpers.formatArtist(raw_artist);
// Already have an artist in the index
if (artists_index[artist.uri]) {
if (artists_index[artist.uri]) {
// And we've already got some images, make sure we merge the arrays,
// rather than overwriting
if (artists_index[artist.uri].images && artist.images) {
@ -612,7 +612,7 @@ const CoreMiddleware = (function () {
// loop all extisting images to make sure we're not adding one that
// we already have
for (const existing_image of existing_images) {
for (const existing_image of existing_images) {
// We only need to check one size, the formatter should insist on consistency
// Note that we depend on having a one-item array of images provided per action
if (existing_image.huge == artist.images[0].huge) {
@ -654,11 +654,11 @@ const CoreMiddleware = (function () {
var playlists_loaded = [];
var tracks_loaded = [];
for (var playlist of action.playlists) {
for (var playlist of action.playlists) {
playlist = helpers.formatPlaylist(playlist);
// Detect editability
switch (helpers.uriSource(playlist.uri)) {
switch (helpers.uriSource(playlist.uri)) {
case 'm3u':
playlist.can_edit = true;
break;
@ -797,7 +797,7 @@ const CoreMiddleware = (function () {
default:
return next(action);
}
};
};
}());
export default CoreMiddleware;

View File

@ -639,7 +639,7 @@ const MopidyMiddleware = (function () {
.then(
(response) => {
if (!response || response.tracks === undefined || !response.tracks) {
store.dispatch(uiActions.createNotification({ content: 'Failed to load playlist tracks', type: 'bad' }));
store.dispatch(uiActions.createNotification({ content: 'Failed to load playlist tracks', level: 'error' }));
} else {
let tracks_uris = helpers.arrayOf('uri', response.tracks);
if (action.shuffle) {
@ -691,7 +691,7 @@ const MopidyMiddleware = (function () {
.then(
(response) => {
if (response.tracks === undefined) {
store.dispatch(uiActions.createNotification({ content: 'Failed to load playlist tracks', type: 'bad' }));
store.dispatch(uiActions.createNotification({ content: 'Failed to load playlist tracks', level: 'error' }));
} else {
let tracks_uris = helpers.arrayOf('uri', response.tracks);
if (action.shuffle) {
@ -712,7 +712,7 @@ const MopidyMiddleware = (function () {
case 'MOPIDY_ENQUEUE_URIS':
if (!action.uris || action.uris.length <= 0) {
this.props.uiActions.createNotification({ content: 'No URIs to enqueue', type: 'warning' });
this.props.uiActions.createNotification({ content: 'No URIs to enqueue', level: 'warning' });
break;
}
@ -855,7 +855,7 @@ const MopidyMiddleware = (function () {
let urisToPlay = Object.assign([], action.uris);
if (!urisToPlay || !urisToPlay.length) {
this.props.uiActions.createNotification({ content: 'No URIs to play', type: 'warning' });
this.props.uiActions.createNotification({ content: 'No URIs to play', level: 'warning' });
break;
}
@ -983,7 +983,7 @@ const MopidyMiddleware = (function () {
var uri_scheme = uri_schemes.shift();
if (uri_schemes_total <= 0) {
store.dispatch(uiActions.createNotification({ content: 'No sources selected', type: 'warning' }));
store.dispatch(uiActions.createNotification({ content: 'No sources selected', level: 'warning' }));
} else {
store.dispatch(uiActions.startProcess(
'MOPIDY_GET_SEARCH_RESULTS_PROCESSOR',
@ -1745,7 +1745,7 @@ const MopidyMiddleware = (function () {
store.dispatch(coreActions.playlistLoaded(playlist));
store.dispatch(uiActions.createNotification({ type: 'info', content: 'Playlist saved' }));
store.dispatch(uiActions.createNotification({ level: 'warning', content: 'Playlist saved' }));
});
});
break;
@ -1793,7 +1793,7 @@ const MopidyMiddleware = (function () {
case 'MOPIDY_CREATE_PLAYLIST':
request(socket, store, 'playlists.create', { name: action.name, uri_scheme: action.scheme })
.then((response) => {
store.dispatch(uiActions.createNotification({ type: 'info', content: 'Created playlist' }));
store.dispatch(uiActions.createNotification({ level: 'warning', content: 'Created playlist' }));
store.dispatch(coreActions.playlistLoaded(response));
store.dispatch({
type: 'MOPIDY_LIBRARY_PLAYLIST_CREATED',

View File

@ -342,7 +342,7 @@ const PusherMiddleware = (function () {
request(store, 'send_message', action.data)
.then(
(response) => {
store.dispatch(uiActions.createNotification({ type: 'info', content: 'Message delivered' }));
store.dispatch(uiActions.createNotification({ level: 'warning', content: 'Message delivered' }));
},
(error) => {
store.dispatch(coreActions.handleException(
@ -550,7 +550,7 @@ const PusherMiddleware = (function () {
console.log('Command response', response);
store.dispatch(uiActions.removeProcess(notification_key));
if (action.notify) {
store.dispatch(uiActions.createNotification({ key: notification_key, type: 'info', content: 'Command sent' }));
store.dispatch(uiActions.createNotification({ key: notification_key, level: 'warning', content: 'Command sent' }));
}
},
(error) => {
@ -629,7 +629,7 @@ const PusherMiddleware = (function () {
'notification',
{
notification: {
type: 'info',
level: 'warning',
content: `${pusher.username} is starting radio mode`,
},
},
@ -641,7 +641,7 @@ const PusherMiddleware = (function () {
(response) => {
store.dispatch(uiActions.processFinished('PUSHER_RADIO_PROCESS'));
if (response.status == 0) {
store.dispatch(uiActions.createNotification({ content: response.message, type: 'bad' }));
store.dispatch(uiActions.createNotification({ content: response.message, level: 'error' }));
}
store.dispatch(pusherActions.radioChanged(response.radio));
},
@ -666,7 +666,7 @@ const PusherMiddleware = (function () {
'notification',
{
notification: {
type: 'info',
level: 'warning',
content: `${pusher.username} stopped radio mode`,
},
},

View File

@ -1387,7 +1387,7 @@ export function createPlaylist(name, description, is_public, is_collaborative) {
uris: [response.uri],
});
dispatch(uiActions.createNotification({ type: 'info', content: 'Created playlist' }));
dispatch(uiActions.createNotification({ level: 'warning', content: 'Created playlist' }));
},
(error) => {
dispatch(coreActions.handleException(
@ -1414,7 +1414,7 @@ export function savePlaylist(uri, name, description, is_public, is_collaborative
)
.then(
(response) => {
dispatch(uiActions.createNotification({ type: 'info', content: 'Playlist saved' }));
dispatch(uiActions.createNotification({ level: 'warning', content: 'Playlist saved' }));
// Save the image
if (image) {