Simplifying processes
This commit is contained in:
@ -109902,6 +109902,8 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
|
||||
|
||||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
||||
|
||||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
|
||||
|
||||
|
||||
|
||||
@ -109923,15 +109925,34 @@ var Notifications = /*#__PURE__*/function (_React$Component) {
|
||||
var _super = _createSuper(Notifications);
|
||||
|
||||
function Notifications() {
|
||||
var _this;
|
||||
|
||||
_classCallCheck(this, Notifications);
|
||||
|
||||
return _super.apply(this, arguments);
|
||||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
||||
args[_key] = arguments[_key];
|
||||
}
|
||||
|
||||
_this = _super.call.apply(_super, [this].concat(args));
|
||||
|
||||
_defineProperty(_assertThisInitialized(_this), "renderProcesses", function () {
|
||||
var processesObj = _this.props.processes;
|
||||
var processes = Object(_util_arrays__WEBPACK_IMPORTED_MODULE_10__["indexToArray"])(processesObj).filter(function (process) {
|
||||
return process.notification;
|
||||
});
|
||||
if (!processes) return null;
|
||||
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react__WEBPACK_IMPORTED_MODULE_0__["Fragment"], null, processes.map(function (process) {
|
||||
return _this.renderProcess(process);
|
||||
}));
|
||||
});
|
||||
|
||||
return _this;
|
||||
}
|
||||
|
||||
_createClass(Notifications, [{
|
||||
key: "importConfiguration",
|
||||
value: function importConfiguration(notification_key, configuration) {
|
||||
var _this = this;
|
||||
var _this2 = this;
|
||||
|
||||
if (configuration.ui) {
|
||||
this.props.uiActions.set(configuration.ui);
|
||||
@ -109944,7 +109965,7 @@ var Notifications = /*#__PURE__*/function (_React$Component) {
|
||||
if (configuration.snapcast) {
|
||||
this.props.snapcastActions.set(configuration.snapcast);
|
||||
setTimeout(function () {
|
||||
return _this.props.snapcastActions.connect();
|
||||
return _this2.props.snapcastActions.connect();
|
||||
}, 100);
|
||||
}
|
||||
|
||||
@ -109964,7 +109985,7 @@ var Notifications = /*#__PURE__*/function (_React$Component) {
|
||||
}, {
|
||||
key: "renderNotifications",
|
||||
value: function renderNotifications() {
|
||||
var _this2 = this;
|
||||
var _this3 = this;
|
||||
|
||||
if (!this.props.notifications || this.props.notifications.length <= 0) return null;
|
||||
var notifications = Object(_util_arrays__WEBPACK_IMPORTED_MODULE_10__["indexToArray"])(this.props.notifications);
|
||||
@ -110006,7 +110027,7 @@ var Notifications = /*#__PURE__*/function (_React$Component) {
|
||||
name: "close",
|
||||
className: "notification__close-button",
|
||||
onClick: function onClick(e) {
|
||||
return _this2.props.uiActions.removeNotification(notification.key, true);
|
||||
return _this3.props.uiActions.removeNotification(notification.key, true);
|
||||
},
|
||||
"data-qa-node": "Icon",
|
||||
"data-qa-file": "Notifications"
|
||||
@ -110081,7 +110102,7 @@ var Notifications = /*#__PURE__*/function (_React$Component) {
|
||||
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_Button__WEBPACK_IMPORTED_MODULE_13__["default"], {
|
||||
className: "notification__actions__item",
|
||||
onClick: function onClick() {
|
||||
return _this2.importConfiguration(notification.key, notification.configuration);
|
||||
return _this3.importConfiguration(notification.key, notification.configuration);
|
||||
},
|
||||
tracking: {
|
||||
category: 'ShareConfiguration',
|
||||
@ -110111,7 +110132,7 @@ var Notifications = /*#__PURE__*/function (_React$Component) {
|
||||
name: "close",
|
||||
className: "notification__close-button",
|
||||
onClick: function onClick() {
|
||||
return _this2.props.uiActions.removeNotification(notification.key, true);
|
||||
return _this3.props.uiActions.removeNotification(notification.key, true);
|
||||
},
|
||||
"data-qa-node": "Icon",
|
||||
"data-qa-file": "Notifications"
|
||||
@ -110153,9 +110174,8 @@ var Notifications = /*#__PURE__*/function (_React$Component) {
|
||||
}, {
|
||||
key: "renderProcess",
|
||||
value: function renderProcess(process) {
|
||||
var _process$data = process.data,
|
||||
total = _process$data.total,
|
||||
remaining = _process$data.remaining,
|
||||
var total = process.total,
|
||||
remaining = process.remaining,
|
||||
_process$level = process.level,
|
||||
level = _process$level === void 0 ? 'info' : _process$level,
|
||||
content = process.content,
|
||||
@ -110278,21 +110298,6 @@ var Notifications = /*#__PURE__*/function (_React$Component) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: "renderProcesses",
|
||||
value: function renderProcesses() {
|
||||
var _this3 = this;
|
||||
|
||||
var _this$props$processes = this.props.processes,
|
||||
processesObj = _this$props$processes === void 0 ? {} : _this$props$processes;
|
||||
var processes = Object.keys(processesObj).map(function (key) {
|
||||
return processesObj[key];
|
||||
});
|
||||
if (!processes.length) return null;
|
||||
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(react__WEBPACK_IMPORTED_MODULE_0__["Fragment"], null, processes.map(function (process) {
|
||||
return _this3.renderProcess(process);
|
||||
}));
|
||||
}
|
||||
}, {
|
||||
key: "render",
|
||||
value: function render() {
|
||||
@ -119508,14 +119513,32 @@ var GoogleMiddleware = function () {
|
||||
switch (action.type) {
|
||||
case 'GOOGLE_GET_LIBRARY_ALBUMS':
|
||||
{
|
||||
store.dispatch(uiActions.updateProcess(action.type, {
|
||||
notification: false
|
||||
}));
|
||||
request(store, 'library.browse', {
|
||||
uri: 'gmusic:album'
|
||||
}, function (browseResponse) {
|
||||
var allUris = Object(_util_arrays__WEBPACK_IMPORTED_MODULE_1__["arrayOf"])('uri', browseResponse);
|
||||
store.dispatch(uiActions.updateProcess('GOOGLE_GET_LIBRARY_ALBUMS', {
|
||||
remaining: allUris.length,
|
||||
total: allUris.length
|
||||
}));
|
||||
|
||||
var run = function run() {
|
||||
if (allUris.length) {
|
||||
var uris = allUris.splice(0, 5);
|
||||
var processor = store.getState().ui.processes[action.type];
|
||||
|
||||
if (processor && processor.status === 'cancelling') {
|
||||
store.dispatch(uiActions.processCancelled(action.type));
|
||||
store.dispatch(uiActions.stopLoading('google:library:artists'));
|
||||
return;
|
||||
}
|
||||
|
||||
store.dispatch(uiActions.updateProcess(action.type, {
|
||||
remaining: allUris.length
|
||||
}));
|
||||
request(store, 'library.lookup', {
|
||||
uris: uris
|
||||
}, function (lookupResponse) {
|
||||
@ -119536,6 +119559,7 @@ var GoogleMiddleware = function () {
|
||||
run();
|
||||
});
|
||||
} else {
|
||||
store.dispatch(uiActions.processFinished(action.type));
|
||||
store.dispatch(coreActions.libraryLoaded({
|
||||
uri: 'google:library:albums',
|
||||
items_uris: Object(_util_arrays__WEBPACK_IMPORTED_MODULE_1__["arrayOf"])('uri', allUris)
|
||||
@ -119550,17 +119574,13 @@ var GoogleMiddleware = function () {
|
||||
|
||||
case 'GOOGLE_GET_LIBRARY_ARTISTS':
|
||||
{
|
||||
store.dispatch(uiActions.updateProcess('GOOGLE_GET_LIBRARY_ARTISTS', Object(_locale__WEBPACK_IMPORTED_MODULE_3__["i18n"])('common.loading_library', {
|
||||
provider: Object(_locale__WEBPACK_IMPORTED_MODULE_3__["i18n"])('services.google.title'),
|
||||
type: Object(_locale__WEBPACK_IMPORTED_MODULE_3__["i18n"])('artist.title')
|
||||
})));
|
||||
store.dispatch(uiActions.updateProcess(action.type, {
|
||||
notification: false
|
||||
}));
|
||||
request(store, 'library.browse', {
|
||||
uri: 'gmusic:artist'
|
||||
}, function (browseResponse) {
|
||||
store.dispatch(uiActions.updateProcess('GOOGLE_GET_LIBRARY_ARTISTS', Object(_locale__WEBPACK_IMPORTED_MODULE_3__["i18n"])('common.loading_library', {
|
||||
provider: Object(_locale__WEBPACK_IMPORTED_MODULE_3__["i18n"])('services.google.title'),
|
||||
type: Object(_locale__WEBPACK_IMPORTED_MODULE_3__["i18n"])('artist.title')
|
||||
}), {
|
||||
store.dispatch(uiActions.updateProcess(action.type, {
|
||||
remaining: browseResponse.length,
|
||||
total: browseResponse.length
|
||||
}));
|
||||
@ -119568,17 +119588,15 @@ var GoogleMiddleware = function () {
|
||||
|
||||
var run = function run() {
|
||||
var uris = allUris.splice(0, 5);
|
||||
var processor = store.getState().ui.processes.GOOGLE_GET_LIBRARY_ARTISTS;
|
||||
var processor = store.getState().ui.processes[action.type];
|
||||
|
||||
if (processor && processor.status === 'cancelling') {
|
||||
store.dispatch(uiActions.processCancelled('GOOGLE_GET_LIBRARY_ARTISTS'));
|
||||
store.dispatch(uiActions.processCancelled(action.type));
|
||||
store.dispatch(uiActions.stopLoading('google:library:artists'));
|
||||
return;
|
||||
}
|
||||
|
||||
store.dispatch(uiActions.updateProcess('GOOGLE_GET_LIBRARY_ARTISTS', Object(_locale__WEBPACK_IMPORTED_MODULE_3__["i18n"])('common.loading_library', {
|
||||
provider: Object(_locale__WEBPACK_IMPORTED_MODULE_3__["i18n"])('services.google.title'),
|
||||
type: Object(_locale__WEBPACK_IMPORTED_MODULE_3__["i18n"])('artist.title')
|
||||
}), {
|
||||
store.dispatch(uiActions.updateProcess(action.type, {
|
||||
remaining: allUris.length
|
||||
}));
|
||||
|
||||
@ -119603,7 +119621,7 @@ var GoogleMiddleware = function () {
|
||||
run();
|
||||
});
|
||||
} else {
|
||||
store.dispatch(uiActions.processFinished('GOOGLE_GET_LIBRARY_ARTISTS'));
|
||||
store.dispatch(uiActions.processFinished(action.type));
|
||||
store.dispatch(coreActions.libraryLoaded({
|
||||
uri: 'google:library:artists',
|
||||
items_uris: Object(_util_arrays__WEBPACK_IMPORTED_MODULE_1__["arrayOf"])('uri', allUris)
|
||||
@ -122716,6 +122734,9 @@ var MopidyMiddleware = function () {
|
||||
*/
|
||||
|
||||
case 'MOPIDY_GET_LIBRARY_ARTISTS':
|
||||
store.dispatch(uiActions.startProcess('MOPIDY_GET_LIBRARY_ARTISTS', {
|
||||
notification: false
|
||||
}));
|
||||
request(store, 'library.browse', {
|
||||
uri: store.getState().mopidy.library_artists_uri
|
||||
}).then(function (raw_response) {
|
||||
@ -122732,17 +122753,25 @@ var MopidyMiddleware = function () {
|
||||
uri: 'mopidy:library:artists',
|
||||
items_uris: Object(_util_arrays__WEBPACK_IMPORTED_MODULE_7__["arrayOf"])('uri', response)
|
||||
}));
|
||||
store.dispatch(uiActions.processFinished('MOPIDY_GET_LIBRARY_ARTISTS'));
|
||||
});
|
||||
break;
|
||||
|
||||
case 'MOPIDY_GET_LIBRARY_PLAYLISTS':
|
||||
{
|
||||
store.dispatch(uiActions.startProcess('MOPIDY_GET_LIBRARY_PLAYLISTS', {
|
||||
notification: false
|
||||
}));
|
||||
request(store, 'playlists.asList').then(function (listResponse) {
|
||||
// Remove any Spotify playlists. These will be handled by our Spotify API
|
||||
var playlist_uris = Object(_util_arrays__WEBPACK_IMPORTED_MODULE_7__["arrayOf"])('uri', listResponse).filter(function (playlistUri) {
|
||||
return Object(_util_helpers__WEBPACK_IMPORTED_MODULE_5__["uriSource"])(playlistUri) !== 'spotify';
|
||||
});
|
||||
var libraryPlaylists = [];
|
||||
store.dispatch(uiActions.updateProcess('MOPIDY_GET_LIBRARY_PLAYLISTS', {
|
||||
total: playlist_uris.length,
|
||||
remaining: playlist_uris.length
|
||||
}));
|
||||
|
||||
if (playlist_uris.length) {
|
||||
playlist_uris.forEach(function (uri, index) {
|
||||
@ -122758,6 +122787,9 @@ var MopidyMiddleware = function () {
|
||||
// want these simple tracks because they don't contain duration, artist, etc.
|
||||
tracks_total: response.tracks ? response.tracks.length : null
|
||||
}));
|
||||
store.dispatch(uiActions.updateProcess('MOPIDY_GET_LIBRARY_PLAYLISTS', {
|
||||
remaining: playlist_uris.length - index - 1
|
||||
}));
|
||||
|
||||
if (index === playlist_uris.length - 1) {
|
||||
store.dispatch(coreActions.itemsLoaded(libraryPlaylists));
|
||||
@ -122765,21 +122797,30 @@ var MopidyMiddleware = function () {
|
||||
uri: 'mopidy:library:playlists',
|
||||
items_uris: Object(_util_arrays__WEBPACK_IMPORTED_MODULE_7__["arrayOf"])('uri', libraryPlaylists)
|
||||
}));
|
||||
store.dispatch(uiActions.processFinished('MOPIDY_GET_LIBRARY_PLAYLISTS'));
|
||||
}
|
||||
});
|
||||
});
|
||||
} else {
|
||||
store.dispatch(uiActions.stopLoading('mopidy:library:playlists'));
|
||||
store.dispatch(uiActions.processFinished('MOPIDY_GET_LIBRARY_PLAYLISTS'));
|
||||
}
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
||||
case 'MOPIDY_GET_LIBRARY_ALBUMS':
|
||||
store.dispatch(uiActions.startProcess('MOPIDY_GET_LIBRARY_ALBUMS', {
|
||||
notification: false
|
||||
}));
|
||||
request(store, 'library.browse', {
|
||||
uri: store.getState().mopidy.library_albums_uri
|
||||
}).then(function (response) {
|
||||
var uris = Object(_util_arrays__WEBPACK_IMPORTED_MODULE_7__["arrayOf"])('uri', response);
|
||||
store.dispatch(uiActions.updateProcess('MOPIDY_GET_LIBRARY_ALBUMS', {
|
||||
total: uris.length,
|
||||
remaining: uris.length
|
||||
}));
|
||||
request(store, 'library.lookup', {
|
||||
uris: uris
|
||||
}).then(function (response) {
|
||||
@ -122790,11 +122831,13 @@ var MopidyMiddleware = function () {
|
||||
last_modified: tracks[0].last_modified
|
||||
}, Object(_util_format__WEBPACK_IMPORTED_MODULE_6__["formatAlbum"])(tracks[0].album));
|
||||
});
|
||||
console.log('LOADED', response);
|
||||
store.dispatch(coreActions.itemsLoaded(libraryAlbums));
|
||||
store.dispatch(coreActions.libraryLoaded({
|
||||
uri: 'mopidy:library:albums',
|
||||
items_uris: Object(_util_arrays__WEBPACK_IMPORTED_MODULE_7__["arrayOf"])('uri', libraryAlbums)
|
||||
}));
|
||||
store.dispatch(uiActions.processFinished('MOPIDY_GET_LIBRARY_ALBUMS'));
|
||||
});
|
||||
});
|
||||
break;
|
||||
@ -126602,10 +126645,26 @@ function flushLibrary() {
|
||||
}
|
||||
function getLibraryPlaylists(forceRefetch) {
|
||||
return function (dispatch, getState) {
|
||||
var processKey = 'SPOTIFY_GET_LIBRARY_PLAYLISTS';
|
||||
dispatch(uiActions.updateProcess(processKey, {
|
||||
notification: false
|
||||
}));
|
||||
var libraryItems = [];
|
||||
|
||||
var fetchLibraryPlaylists = function fetchLibraryPlaylists(endpoint) {
|
||||
return request(dispatch, getState, endpoint).then(function (response) {
|
||||
var processor = getState().ui.processes[processKey];
|
||||
|
||||
if (processor && processor.status === 'cancelling') {
|
||||
dispatch(uiActions.processCancelled(processKey));
|
||||
dispatch(uiActions.stopLoading('spotify:library:albums'));
|
||||
return;
|
||||
}
|
||||
|
||||
dispatch(uiActions.updateProcess(processKey, {
|
||||
total: response.total,
|
||||
remaining: response.total - libraryItems.length
|
||||
}));
|
||||
var items = response.items.map(function (item) {
|
||||
return _objectSpread(_objectSpread({}, Object(_util_format__WEBPACK_IMPORTED_MODULE_3__["formatPlaylist"])(item)), {}, {
|
||||
in_library: true,
|
||||
@ -126617,6 +126676,7 @@ function getLibraryPlaylists(forceRefetch) {
|
||||
if (response.next) {
|
||||
fetchLibraryPlaylists("".concat(response.next).concat(forceRefetch ? "&refetch=".concat(Date.now()) : ''));
|
||||
} else {
|
||||
dispatch(uiActions.processFinished(processKey));
|
||||
dispatch(coreActions.itemsLoaded(libraryItems));
|
||||
dispatch(coreActions.libraryLoaded({
|
||||
uri: 'spotify:library:playlists',
|
||||
@ -126631,10 +126691,26 @@ function getLibraryPlaylists(forceRefetch) {
|
||||
}
|
||||
function getLibraryAlbums(forceRefetch) {
|
||||
return function (dispatch, getState) {
|
||||
var processKey = 'SPOTIFY_GET_LIBRARY_ALBUMS';
|
||||
dispatch(uiActions.updateProcess(processKey, {
|
||||
notification: false
|
||||
}));
|
||||
var libraryItems = [];
|
||||
|
||||
var fetchLibraryAlbums = function fetchLibraryAlbums(endpoint) {
|
||||
return request(dispatch, getState, endpoint).then(function (response) {
|
||||
var processor = getState().ui.processes[processKey];
|
||||
|
||||
if (processor && processor.status === 'cancelling') {
|
||||
dispatch(uiActions.processCancelled(processKey));
|
||||
dispatch(uiActions.stopLoading('spotify:library:albums'));
|
||||
return;
|
||||
}
|
||||
|
||||
dispatch(uiActions.updateProcess(processKey, {
|
||||
total: response.total,
|
||||
remaining: response.total - libraryItems.length
|
||||
}));
|
||||
var items = response.items.map(function (item) {
|
||||
return _objectSpread(_objectSpread({}, Object(_util_format__WEBPACK_IMPORTED_MODULE_3__["formatAlbum"])(item)), {}, {
|
||||
in_library: true
|
||||
@ -126645,6 +126721,7 @@ function getLibraryAlbums(forceRefetch) {
|
||||
if (response.next) {
|
||||
fetchLibraryAlbums("".concat(response.next).concat(forceRefetch ? "&refetch=".concat(Date.now()) : ''));
|
||||
} else {
|
||||
dispatch(uiActions.processFinished(processKey));
|
||||
dispatch(coreActions.itemsLoaded(libraryItems));
|
||||
dispatch(coreActions.libraryLoaded({
|
||||
uri: 'spotify:library:albums',
|
||||
@ -126659,10 +126736,26 @@ function getLibraryAlbums(forceRefetch) {
|
||||
}
|
||||
function getLibraryArtists(forceRefetch) {
|
||||
return function (dispatch, getState) {
|
||||
var processKey = 'SPOTIFY_GET_LIBRARY_ARTISTS';
|
||||
dispatch(uiActions.updateProcess(processKey, {
|
||||
notification: false
|
||||
}));
|
||||
var libraryItems = [];
|
||||
|
||||
var fetchLibraryArtists = function fetchLibraryArtists(endpoint) {
|
||||
return request(dispatch, getState, endpoint).then(function (response) {
|
||||
var processor = getState().ui.processes[processKey];
|
||||
|
||||
if (processor && processor.status === 'cancelling') {
|
||||
dispatch(uiActions.processCancelled(processKey));
|
||||
dispatch(uiActions.stopLoading('spotify:library:artists'));
|
||||
return;
|
||||
}
|
||||
|
||||
dispatch(uiActions.updateProcess(processKey, {
|
||||
total: response.artists.total,
|
||||
remaining: response.artists.total - libraryItems.length
|
||||
}));
|
||||
var items = response.artists.items.map(function (item) {
|
||||
return _objectSpread(_objectSpread({}, Object(_util_format__WEBPACK_IMPORTED_MODULE_3__["formatArtist"])(item)), {}, {
|
||||
in_library: true
|
||||
@ -126673,6 +126766,7 @@ function getLibraryArtists(forceRefetch) {
|
||||
if (response.next) {
|
||||
fetchLibraryArtists("".concat(response.next).concat(forceRefetch ? "&refetch=".concat(Date.now()) : ''));
|
||||
} else {
|
||||
dispatch(uiActions.processFinished(processKey));
|
||||
dispatch(coreActions.itemsLoaded(libraryItems));
|
||||
dispatch(coreActions.libraryLoaded({
|
||||
uri: 'spotify:library:artists',
|
||||
@ -127361,7 +127455,7 @@ function reducer() {
|
||||
/*!***************************************!*\
|
||||
!*** ./src/js/services/ui/actions.js ***!
|
||||
\***************************************/
|
||||
/*! exports provided: getBroadcasts, setWindowTitle, setCurrentTrackTransition, setSelectedTracks, showContextMenu, setSlimMode, setWindowFocus, setLanguage, hideContextMenu, removeContextMenu, showTouchContextMenu, hideTouchContextMenu, removeTouchContextMenu, lazyLoading, toggleSidebar, dragStart, dragActive, dragEnd, set, installPrompt, createBrowserNotification, createNotification, closeNotification, removeNotification, startLoading, stopLoading, startProcess, resumeProcess, updateProcess, runProcess, cancelProcess, processCancelled, processFinished, closeProcess, removeProcess */
|
||||
/*! exports provided: getBroadcasts, setWindowTitle, setCurrentTrackTransition, setSelectedTracks, showContextMenu, setSlimMode, setWindowFocus, setLanguage, hideContextMenu, removeContextMenu, showTouchContextMenu, hideTouchContextMenu, removeTouchContextMenu, lazyLoading, toggleSidebar, dragStart, dragActive, dragEnd, set, installPrompt, createBrowserNotification, createNotification, closeNotification, removeNotification, startLoading, stopLoading, startProcess, updateProcess, runProcess, cancelProcess, processCancelled, processFinished, closeProcess, removeProcess */
|
||||
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
||||
|
||||
"use strict";
|
||||
@ -127393,7 +127487,6 @@ __webpack_require__.r(__webpack_exports__);
|
||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "startLoading", function() { return startLoading; });
|
||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "stopLoading", function() { return stopLoading; });
|
||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "startProcess", function() { return startProcess; });
|
||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "resumeProcess", function() { return resumeProcess; });
|
||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "updateProcess", function() { return updateProcess; });
|
||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "runProcess", function() { return runProcess; });
|
||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "cancelProcess", function() { return cancelProcess; });
|
||||
@ -127658,34 +127751,18 @@ function stopLoading(keys) {
|
||||
keys: Array.isArray(keys) ? keys : [keys]
|
||||
};
|
||||
}
|
||||
function startProcess(key, content) {
|
||||
var data = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
||||
var description = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
|
||||
function startProcess(key, process) {
|
||||
return {
|
||||
type: 'START_PROCESS',
|
||||
key: key,
|
||||
data: data,
|
||||
content: content,
|
||||
description: description
|
||||
process: process
|
||||
};
|
||||
}
|
||||
function resumeProcess(key) {
|
||||
return {
|
||||
type: 'RESUME_PROCESS',
|
||||
key: key
|
||||
};
|
||||
}
|
||||
function updateProcess(key, content) {
|
||||
var data = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
||||
var description = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
|
||||
var level = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 'info';
|
||||
function updateProcess(key, process) {
|
||||
return {
|
||||
type: 'UPDATE_PROCESS',
|
||||
key: key,
|
||||
content: content,
|
||||
data: data,
|
||||
description: description,
|
||||
level: level
|
||||
process: process
|
||||
};
|
||||
}
|
||||
function runProcess(key) {
|
||||
@ -127928,25 +128005,6 @@ var UIMiddleware = function () {
|
||||
next(action);
|
||||
break;
|
||||
|
||||
case 'START_PROCESS':
|
||||
store.dispatch({
|
||||
type: action.key,
|
||||
data: action.data
|
||||
});
|
||||
store.dispatch({
|
||||
type: "".concat(action.key, "_STARTED")
|
||||
});
|
||||
next(action);
|
||||
break;
|
||||
|
||||
case 'RESUME_PROCESS':
|
||||
store.dispatch({
|
||||
type: action.key,
|
||||
data: store.getState().ui.processes[action.key].data
|
||||
});
|
||||
next(action);
|
||||
break;
|
||||
|
||||
case 'PROCESS_CANCELLED':
|
||||
store.dispatch({
|
||||
type: "".concat(action.key, "_CANCELLED")
|
||||
@ -128237,110 +128295,99 @@ function reducer() {
|
||||
|
||||
case 'START_PROCESS':
|
||||
case 'UPDATE_PROCESS':
|
||||
var processes = _objectSpread({}, ui.processes || []);
|
||||
{
|
||||
var _processes = _objectSpread({}, ui.processes || []);
|
||||
|
||||
var last_run = processes[action.key];
|
||||
var status = 'running';
|
||||
|
||||
if (last_run) {
|
||||
var data = _objectSpread(_objectSpread({}, last_run.data), action.data);
|
||||
|
||||
if (action.type === 'UPDATE_PROCESS') status = last_run.status;
|
||||
} else {
|
||||
var data = action.data;
|
||||
}
|
||||
|
||||
processes[action.key] = {
|
||||
key: action.key,
|
||||
content: action.content,
|
||||
description: action.description,
|
||||
level: action.level,
|
||||
status: status,
|
||||
data: data
|
||||
};
|
||||
return _objectSpread(_objectSpread({}, ui), {}, {
|
||||
processes: processes
|
||||
});
|
||||
|
||||
case 'RESUME_PROCESS':
|
||||
var processes = _objectSpread({}, ui.processes ? ui.processes : {});
|
||||
|
||||
if (processes[action.key]) {
|
||||
processes[action.key] = _objectSpread(_objectSpread({}, processes[action.key]), {}, {
|
||||
status: 'running'
|
||||
_processes[action.key] = _objectSpread(_objectSpread(_objectSpread({
|
||||
key: action.key
|
||||
}, _processes[action.key] || {
|
||||
notification: true
|
||||
}), action.type === 'START_PROCESS' ? {
|
||||
status: 'running',
|
||||
remaining: 0,
|
||||
total: 0
|
||||
} : {}), action.process);
|
||||
return _objectSpread(_objectSpread({}, ui), {}, {
|
||||
processes: _processes
|
||||
});
|
||||
}
|
||||
|
||||
return _objectSpread(_objectSpread({}, ui), {}, {
|
||||
processes: processes
|
||||
});
|
||||
|
||||
case 'CANCEL_PROCESS':
|
||||
var processes = _objectSpread({}, ui.processes ? ui.processes : {});
|
||||
{
|
||||
var _processes2 = _objectSpread({}, ui.processes ? ui.processes : {});
|
||||
|
||||
if (processes[action.key]) {
|
||||
processes[action.key] = _objectSpread(_objectSpread({}, processes[action.key]), {}, {
|
||||
status: 'cancelling'
|
||||
if (_processes2[action.key]) {
|
||||
_processes2[action.key] = _objectSpread(_objectSpread({}, _processes2[action.key]), {}, {
|
||||
status: 'cancelling'
|
||||
});
|
||||
}
|
||||
|
||||
return _objectSpread(_objectSpread({}, ui), {}, {
|
||||
processes: _processes2
|
||||
});
|
||||
}
|
||||
|
||||
return _objectSpread(_objectSpread({}, ui), {}, {
|
||||
processes: processes
|
||||
});
|
||||
|
||||
case 'PROCESS_CANCELLED':
|
||||
var processes = _objectSpread({}, ui.processes ? ui.processes : {});
|
||||
{
|
||||
var processes = _objectSpread({}, ui.processes ? ui.processes : {});
|
||||
|
||||
if (processes[action.key]) {
|
||||
processes[action.key] = _objectSpread(_objectSpread({}, processes[action.key]), {}, {
|
||||
status: 'cancelled'
|
||||
if (processes[action.key]) {
|
||||
processes[action.key] = _objectSpread(_objectSpread({}, processes[action.key]), {}, {
|
||||
status: 'cancelled'
|
||||
});
|
||||
}
|
||||
|
||||
return _objectSpread(_objectSpread({}, ui), {}, {
|
||||
processes: processes
|
||||
});
|
||||
}
|
||||
|
||||
return _objectSpread(_objectSpread({}, ui), {}, {
|
||||
processes: processes
|
||||
});
|
||||
|
||||
case 'PROCESS_FINISHED':
|
||||
var processes = _objectSpread({}, ui.processes ? ui.processes : {});
|
||||
{
|
||||
var processes = _objectSpread({}, ui.processes ? ui.processes : {});
|
||||
|
||||
if (processes[action.key]) {
|
||||
processes[action.key] = _objectSpread(_objectSpread({}, processes[action.key]), {}, {
|
||||
status: 'finished'
|
||||
if (processes[action.key]) {
|
||||
processes[action.key] = _objectSpread(_objectSpread({}, processes[action.key]), {}, {
|
||||
status: 'finished'
|
||||
});
|
||||
}
|
||||
|
||||
return _objectSpread(_objectSpread({}, ui), {}, {
|
||||
processes: processes
|
||||
});
|
||||
}
|
||||
|
||||
return _objectSpread(_objectSpread({}, ui), {}, {
|
||||
processes: processes
|
||||
});
|
||||
|
||||
case 'CLOSE_PROCESS':
|
||||
var processes = _objectSpread({}, ui.processes ? ui.processes : {});
|
||||
{
|
||||
var processes = _objectSpread({}, ui.processes ? ui.processes : {});
|
||||
|
||||
if (processes[action.key]) {
|
||||
processes[action.key] = _objectSpread(_objectSpread({}, processes[action.key]), {}, {
|
||||
closing: true
|
||||
if (processes[action.key]) {
|
||||
processes[action.key] = _objectSpread(_objectSpread({}, processes[action.key]), {}, {
|
||||
closing: true
|
||||
});
|
||||
}
|
||||
|
||||
return _objectSpread(_objectSpread({}, ui), {}, {
|
||||
processes: processes
|
||||
});
|
||||
}
|
||||
|
||||
return _objectSpread(_objectSpread({}, ui), {}, {
|
||||
processes: processes
|
||||
});
|
||||
|
||||
case 'REMOVE_PROCESS':
|
||||
var processes = _objectSpread({}, ui.processes ? ui.processes : {});
|
||||
{
|
||||
var processes = _objectSpread({}, ui.processes ? ui.processes : {});
|
||||
|
||||
if (processes[action.key]) {
|
||||
processes[action.key] = _objectSpread(_objectSpread({}, processes[action.key]), {}, {
|
||||
status: 'completed',
|
||||
closing: false
|
||||
if (processes[action.key]) {
|
||||
processes[action.key] = _objectSpread(_objectSpread({}, processes[action.key]), {}, {
|
||||
status: 'completed',
|
||||
closing: false
|
||||
});
|
||||
}
|
||||
|
||||
return _objectSpread(_objectSpread({}, ui), {}, {
|
||||
processes: processes
|
||||
});
|
||||
}
|
||||
|
||||
return _objectSpread(_objectSpread({}, ui), {}, {
|
||||
processes: processes
|
||||
});
|
||||
|
||||
case 'SUPPRESS_BROADCAST':
|
||||
return _objectSpread(_objectSpread({}, ui), {}, {
|
||||
suppressed_broadcasts: [].concat(_toConsumableArray(ui.suppressed_broadcasts || []), [action.key])
|
||||
@ -133174,7 +133221,7 @@ console.warn('WARN: note that setting Flac.onready handler after Flac.isReady()
|
||||
/*!**********************************!*\
|
||||
!*** ./src/js/util/selectors.js ***!
|
||||
\**********************************/
|
||||
/*! exports provided: getItem, getLibrary, getGridGlowEnabled, makeItemSelector, makeLibrarySelector, makeLoadingSelector, makeSearchResultsSelector, queueHistorySelector */
|
||||
/*! exports provided: getItem, getLibrary, getGridGlowEnabled, makeItemSelector, makeLibrarySelector, makeLoadingSelector, makeSearchResultsSelector, makeProcessProgressSelector, queueHistorySelector */
|
||||
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
||||
|
||||
"use strict";
|
||||
@ -133186,6 +133233,7 @@ __webpack_require__.r(__webpack_exports__);
|
||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "makeLibrarySelector", function() { return makeLibrarySelector; });
|
||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "makeLoadingSelector", function() { return makeLoadingSelector; });
|
||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "makeSearchResultsSelector", function() { return makeSearchResultsSelector; });
|
||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "makeProcessProgressSelector", function() { return makeProcessProgressSelector; });
|
||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "queueHistorySelector", function() { return queueHistorySelector; });
|
||||
/* harmony import */ var reselect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! reselect */ "./node_modules/reselect/es/index.js");
|
||||
/* harmony import */ var _arrays__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./arrays */ "./src/js/util/arrays.js");
|
||||
@ -133224,6 +133272,10 @@ var getLoadQueue = function getLoadQueue(state) {
|
||||
return state.ui.load_queue;
|
||||
};
|
||||
|
||||
var getProcesses = function getProcesses(state) {
|
||||
return state.ui.processes;
|
||||
};
|
||||
|
||||
var getLibrary = function getLibrary(state, uri) {
|
||||
return state.core.libraries[uri];
|
||||
};
|
||||
@ -133282,6 +133334,25 @@ var makeSearchResultsSelector = function makeSearchResultsSelector(term, type) {
|
||||
});
|
||||
};
|
||||
|
||||
var makeProcessProgressSelector = function makeProcessProgressSelector(keys) {
|
||||
return Object(reselect__WEBPACK_IMPORTED_MODULE_0__["createSelector"])([getProcesses], function (processes) {
|
||||
var selectedProcesses = keys.map(function (key) {
|
||||
return processes[key] || {};
|
||||
});
|
||||
var total = 0;
|
||||
var remaining = 0;
|
||||
selectedProcesses.forEach(function (process) {
|
||||
if (process.total) total += process.total;
|
||||
if (process.remaining) remaining += process.remaining;
|
||||
});
|
||||
console.log({
|
||||
total: total,
|
||||
remaining: remaining
|
||||
});
|
||||
return total && remaining ? ((total - remaining) / total).toFixed(4) : 0;
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
|
||||
/***/ }),
|
||||
@ -141218,16 +141289,19 @@ var LibraryAlbums = /*#__PURE__*/function (_React$Component) {
|
||||
sort = _this$props6.sort,
|
||||
sort_reverse = _this$props6.sort_reverse,
|
||||
view = _this$props6.view,
|
||||
loading = _this$props6.loading;
|
||||
loading = _this$props6.loading,
|
||||
loading_progress = _this$props6.loading_progress;
|
||||
var _this$state2 = _this.state,
|
||||
limit = _this$state2.limit,
|
||||
filter = _this$state2.filter;
|
||||
var albums = _this.props.albums;
|
||||
|
||||
if (loading) {
|
||||
console.log(loading_progress);
|
||||
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_components_Loader__WEBPACK_IMPORTED_MODULE_18__["default"], {
|
||||
body: true,
|
||||
loading: true,
|
||||
progress: loading_progress,
|
||||
"data-qa-node": "Loader",
|
||||
"data-qa-file": "LibraryAlbums"
|
||||
});
|
||||
@ -141490,8 +141564,10 @@ var mapStateToProps = function mapStateToProps(state) {
|
||||
if (source === 'all' || source === 'spotify') libraryUris.push('spotify:library:albums');
|
||||
if (source === 'all' || source === 'google') libraryUris.push('google:library:albums');
|
||||
var librarySelector = Object(_util_selectors__WEBPACK_IMPORTED_MODULE_19__["makeLibrarySelector"])(libraryUris);
|
||||
var processProgressSelector = Object(_util_selectors__WEBPACK_IMPORTED_MODULE_19__["makeProcessProgressSelector"])(['MOPIDY_GET_LIBRARY_ALBUMS', 'SPOTIFY_GET_LIBRARY_ALBUMS', 'GOOGLE_GET_LIBRARY_ALBUMS']);
|
||||
return {
|
||||
loading: loadingSelector(state),
|
||||
loading_progress: processProgressSelector(state),
|
||||
mopidy_uri_schemes: state.mopidy.uri_schemes,
|
||||
albums: librarySelector(state),
|
||||
google_available: state.mopidy.uri_schemes && state.mopidy.uri_schemes.includes('gmusic:'),
|
||||
@ -141703,7 +141779,8 @@ var LibraryArtists = /*#__PURE__*/function (_React$Component) {
|
||||
sort = _this$props5.sort,
|
||||
sort_reverse = _this$props5.sort_reverse,
|
||||
view = _this$props5.view,
|
||||
loading = _this$props5.loading;
|
||||
loading = _this$props5.loading,
|
||||
loading_progress = _this$props5.loading_progress;
|
||||
var _this$state = _this.state,
|
||||
limit = _this$state.limit,
|
||||
filter = _this$state.filter;
|
||||
@ -141713,6 +141790,7 @@ var LibraryArtists = /*#__PURE__*/function (_React$Component) {
|
||||
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_components_Loader__WEBPACK_IMPORTED_MODULE_15__["default"], {
|
||||
body: true,
|
||||
loading: true,
|
||||
progress: loading_progress,
|
||||
"data-qa-node": "Loader",
|
||||
"data-qa-file": "LibraryArtists"
|
||||
});
|
||||
@ -141964,7 +142042,9 @@ var mapStateToProps = function mapStateToProps(state) {
|
||||
if (source === 'all' || source === 'spotify') libraryUris.push('spotify:library:artists');
|
||||
if (source === 'all' || source === 'google') libraryUris.push('google:library:artists');
|
||||
var librarySelector = Object(_util_selectors__WEBPACK_IMPORTED_MODULE_16__["makeLibrarySelector"])(libraryUris);
|
||||
var processProgressSelector = Object(_util_selectors__WEBPACK_IMPORTED_MODULE_16__["makeProcessProgressSelector"])(['MOPIDY_GET_LIBRARY_ARTISTS', 'SPOTIFY_GET_LIBRARY_ARTISTS', 'GOOGLE_GET_LIBRARY_ARTISTS']);
|
||||
return {
|
||||
loading_progress: processProgressSelector(state),
|
||||
mopidy_uri_schemes: state.mopidy.uri_schemes,
|
||||
google_available: state.mopidy.uri_schemes && state.mopidy.uri_schemes.includes('gmusic:'),
|
||||
spotify_available: state.spotify.access_token,
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -106,7 +106,7 @@
|
||||
|
||||
// Release details
|
||||
// These are automatically injected to built HTML
|
||||
var build = "1603129371";
|
||||
var build = "1603178804";
|
||||
var version = "3.53.0";
|
||||
|
||||
// Construct the script tag
|
||||
|
||||
@ -172,7 +172,8 @@ class Notifications extends React.Component {
|
||||
|
||||
renderProcess(process) {
|
||||
const {
|
||||
data: { total, remaining },
|
||||
total,
|
||||
remaining,
|
||||
level = 'info',
|
||||
content,
|
||||
description = null,
|
||||
@ -252,10 +253,10 @@ class Notifications extends React.Component {
|
||||
}
|
||||
}
|
||||
|
||||
renderProcesses() {
|
||||
const { processes: processesObj = {} } = this.props;
|
||||
const processes = Object.keys(processesObj).map((key) => processesObj[key]);
|
||||
if (!processes.length) return null;
|
||||
renderProcesses = () => {
|
||||
const { processes: processesObj } = this.props;
|
||||
const processes = indexToArray(processesObj).filter((process) => process.notification);
|
||||
if (!processes) return null;
|
||||
|
||||
return (
|
||||
<Fragment>
|
||||
|
||||
@ -26,15 +26,37 @@ const GoogleMiddleware = (function () {
|
||||
return (store) => (next) => (action) => {
|
||||
switch (action.type) {
|
||||
case 'GOOGLE_GET_LIBRARY_ALBUMS': {
|
||||
store.dispatch(
|
||||
uiActions.updateProcess(action.type, { notification: false }),
|
||||
);
|
||||
|
||||
request(
|
||||
store,
|
||||
'library.browse',
|
||||
{ uri: 'gmusic:album' },
|
||||
(browseResponse) => {
|
||||
const allUris = arrayOf('uri', browseResponse);
|
||||
|
||||
store.dispatch(uiActions.updateProcess(
|
||||
'GOOGLE_GET_LIBRARY_ALBUMS',
|
||||
{
|
||||
remaining: allUris.length,
|
||||
total: allUris.length,
|
||||
},
|
||||
));
|
||||
|
||||
const run = () => {
|
||||
if (allUris.length) {
|
||||
const uris = allUris.splice(0, 5);
|
||||
const processor = store.getState().ui.processes[action.type];
|
||||
|
||||
if (processor && processor.status === 'cancelling') {
|
||||
store.dispatch(uiActions.processCancelled(action.type));
|
||||
store.dispatch(uiActions.stopLoading('google:library:artists'));
|
||||
return;
|
||||
}
|
||||
store.dispatch(uiActions.updateProcess(action.type, { remaining: allUris.length }));
|
||||
|
||||
request(
|
||||
store,
|
||||
'library.lookup',
|
||||
@ -58,6 +80,7 @@ const GoogleMiddleware = (function () {
|
||||
},
|
||||
);
|
||||
} else {
|
||||
store.dispatch(uiActions.processFinished(action.type));
|
||||
store.dispatch(coreActions.libraryLoaded({
|
||||
uri: 'google:library:albums',
|
||||
items_uris: arrayOf('uri', allUris),
|
||||
@ -72,16 +95,7 @@ const GoogleMiddleware = (function () {
|
||||
}
|
||||
|
||||
case 'GOOGLE_GET_LIBRARY_ARTISTS': {
|
||||
store.dispatch(uiActions.updateProcess(
|
||||
'GOOGLE_GET_LIBRARY_ARTISTS',
|
||||
i18n(
|
||||
'common.loading_library',
|
||||
{
|
||||
provider: i18n('services.google.title'),
|
||||
type: i18n('artist.title'),
|
||||
},
|
||||
),
|
||||
));
|
||||
store.dispatch(uiActions.updateProcess(action.type, { notification: false }));
|
||||
|
||||
request(
|
||||
store,
|
||||
@ -89,14 +103,7 @@ const GoogleMiddleware = (function () {
|
||||
{ uri: 'gmusic:artist' },
|
||||
(browseResponse) => {
|
||||
store.dispatch(uiActions.updateProcess(
|
||||
'GOOGLE_GET_LIBRARY_ARTISTS',
|
||||
i18n(
|
||||
'common.loading_library',
|
||||
{
|
||||
provider: i18n('services.google.title'),
|
||||
type: i18n('artist.title'),
|
||||
},
|
||||
),
|
||||
action.type,
|
||||
{
|
||||
remaining: browseResponse.length,
|
||||
total: browseResponse.length,
|
||||
@ -106,25 +113,14 @@ const GoogleMiddleware = (function () {
|
||||
const allUris = arrayOf('uri', browseResponse);
|
||||
const run = () => {
|
||||
const uris = allUris.splice(0, 5);
|
||||
const processor = store.getState().ui.processes.GOOGLE_GET_LIBRARY_ARTISTS;
|
||||
|
||||
const processor = store.getState().ui.processes[action.type];
|
||||
|
||||
if (processor && processor.status === 'cancelling') {
|
||||
store.dispatch(uiActions.processCancelled('GOOGLE_GET_LIBRARY_ARTISTS'));
|
||||
store.dispatch(uiActions.processCancelled(action.type));
|
||||
store.dispatch(uiActions.stopLoading('google:library:artists'));
|
||||
return;
|
||||
}
|
||||
store.dispatch(uiActions.updateProcess(
|
||||
'GOOGLE_GET_LIBRARY_ARTISTS',
|
||||
i18n(
|
||||
'common.loading_library',
|
||||
{
|
||||
provider: i18n('services.google.title'),
|
||||
type: i18n('artist.title'),
|
||||
},
|
||||
),
|
||||
{
|
||||
remaining: allUris.length,
|
||||
},
|
||||
));
|
||||
store.dispatch(uiActions.updateProcess(action.type, { remaining: allUris.length }));
|
||||
|
||||
if (uris.length) {
|
||||
request(
|
||||
@ -150,7 +146,7 @@ const GoogleMiddleware = (function () {
|
||||
},
|
||||
);
|
||||
} else {
|
||||
store.dispatch(uiActions.processFinished('GOOGLE_GET_LIBRARY_ARTISTS'));
|
||||
store.dispatch(uiActions.processFinished(action.type));
|
||||
store.dispatch(coreActions.libraryLoaded({
|
||||
uri: 'google:library:artists',
|
||||
items_uris: arrayOf('uri', allUris),
|
||||
|
||||
@ -1724,6 +1724,14 @@ const MopidyMiddleware = (function () {
|
||||
* My Music libraries
|
||||
*/
|
||||
case 'MOPIDY_GET_LIBRARY_ARTISTS':
|
||||
store.dispatch(
|
||||
uiActions.startProcess(
|
||||
'MOPIDY_GET_LIBRARY_ARTISTS',
|
||||
{
|
||||
notification: false,
|
||||
},
|
||||
),
|
||||
);
|
||||
request(store, 'library.browse', { uri: store.getState().mopidy.library_artists_uri })
|
||||
.then((raw_response) => {
|
||||
if (raw_response.length <= 0) return;
|
||||
@ -1740,10 +1748,20 @@ const MopidyMiddleware = (function () {
|
||||
uri: 'mopidy:library:artists',
|
||||
items_uris: arrayOf('uri', response),
|
||||
}));
|
||||
store.dispatch(uiActions.processFinished('MOPIDY_GET_LIBRARY_ARTISTS'));
|
||||
});
|
||||
break;
|
||||
|
||||
case 'MOPIDY_GET_LIBRARY_PLAYLISTS': {
|
||||
store.dispatch(
|
||||
uiActions.startProcess(
|
||||
'MOPIDY_GET_LIBRARY_PLAYLISTS',
|
||||
{
|
||||
notification: false,
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
request(store, 'playlists.asList')
|
||||
.then((listResponse) => {
|
||||
|
||||
@ -1753,6 +1771,16 @@ const MopidyMiddleware = (function () {
|
||||
);
|
||||
const libraryPlaylists = [];
|
||||
|
||||
store.dispatch(
|
||||
uiActions.updateProcess(
|
||||
'MOPIDY_GET_LIBRARY_PLAYLISTS',
|
||||
{
|
||||
total: playlist_uris.length,
|
||||
remaining: playlist_uris.length,
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
if (playlist_uris.length) {
|
||||
playlist_uris.forEach((uri, index) => {
|
||||
request(store, 'playlists.lookup', { uri })
|
||||
@ -1769,26 +1797,57 @@ const MopidyMiddleware = (function () {
|
||||
}),
|
||||
);
|
||||
|
||||
store.dispatch(
|
||||
uiActions.updateProcess(
|
||||
'MOPIDY_GET_LIBRARY_PLAYLISTS',
|
||||
{
|
||||
remaining: playlist_uris.length - index - 1,
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
if (index === playlist_uris.length - 1) {
|
||||
store.dispatch(coreActions.itemsLoaded(libraryPlaylists));
|
||||
store.dispatch(coreActions.libraryLoaded({
|
||||
uri: 'mopidy:library:playlists',
|
||||
items_uris: arrayOf('uri', libraryPlaylists),
|
||||
}));
|
||||
store.dispatch(uiActions.processFinished('MOPIDY_GET_LIBRARY_PLAYLISTS'));
|
||||
}
|
||||
});
|
||||
});
|
||||
} else {
|
||||
store.dispatch(uiActions.stopLoading('mopidy:library:playlists'));
|
||||
store.dispatch(uiActions.processFinished('MOPIDY_GET_LIBRARY_PLAYLISTS'));
|
||||
}
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
||||
case 'MOPIDY_GET_LIBRARY_ALBUMS':
|
||||
store.dispatch(
|
||||
uiActions.startProcess(
|
||||
'MOPIDY_GET_LIBRARY_ALBUMS',
|
||||
{
|
||||
notification: false,
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
request(store, 'library.browse', { uri: store.getState().mopidy.library_albums_uri })
|
||||
.then((response) => {
|
||||
const uris = arrayOf('uri', response);
|
||||
|
||||
store.dispatch(
|
||||
uiActions.updateProcess(
|
||||
'MOPIDY_GET_LIBRARY_ALBUMS',
|
||||
{
|
||||
total: uris.length,
|
||||
remaining: uris.length,
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
request(store, 'library.lookup', { uris })
|
||||
.then((response) => {
|
||||
const libraryAlbums = indexToArray(response).map((tracks) => ({
|
||||
@ -1798,11 +1857,14 @@ const MopidyMiddleware = (function () {
|
||||
...formatAlbum(tracks[0].album),
|
||||
}));
|
||||
|
||||
console.log('LOADED', response);
|
||||
|
||||
store.dispatch(coreActions.itemsLoaded(libraryAlbums));
|
||||
store.dispatch(coreActions.libraryLoaded({
|
||||
uri: 'mopidy:library:albums',
|
||||
items_uris: arrayOf('uri', libraryAlbums),
|
||||
}));
|
||||
store.dispatch(uiActions.processFinished('MOPIDY_GET_LIBRARY_ALBUMS'));
|
||||
});
|
||||
});
|
||||
break;
|
||||
|
||||
@ -1574,9 +1574,24 @@ export function flushLibrary() {
|
||||
|
||||
export function getLibraryPlaylists(forceRefetch) {
|
||||
return (dispatch, getState) => {
|
||||
const processKey = 'SPOTIFY_GET_LIBRARY_PLAYLISTS';
|
||||
dispatch(uiActions.updateProcess(processKey, { notification: false }));
|
||||
|
||||
let libraryItems = [];
|
||||
const fetchLibraryPlaylists = (endpoint) => request(dispatch, getState, endpoint)
|
||||
.then((response) => {
|
||||
const processor = getState().ui.processes[processKey];
|
||||
if (processor && processor.status === 'cancelling') {
|
||||
dispatch(uiActions.processCancelled(processKey));
|
||||
dispatch(uiActions.stopLoading('spotify:library:albums'));
|
||||
return;
|
||||
}
|
||||
|
||||
dispatch(uiActions.updateProcess(
|
||||
processKey,
|
||||
{ total: response.total, remaining: response.total - libraryItems.length },
|
||||
));
|
||||
|
||||
const items = response.items.map(
|
||||
(item) => ({
|
||||
...formatPlaylist(item),
|
||||
@ -1588,6 +1603,7 @@ export function getLibraryPlaylists(forceRefetch) {
|
||||
if (response.next) {
|
||||
fetchLibraryPlaylists(`${response.next}${forceRefetch ? `&refetch=${Date.now()}` : ''}`);
|
||||
} else {
|
||||
dispatch(uiActions.processFinished(processKey));
|
||||
dispatch(coreActions.itemsLoaded(libraryItems));
|
||||
dispatch(coreActions.libraryLoaded({
|
||||
uri: 'spotify:library:playlists',
|
||||
@ -1602,9 +1618,24 @@ export function getLibraryPlaylists(forceRefetch) {
|
||||
|
||||
export function getLibraryAlbums(forceRefetch) {
|
||||
return (dispatch, getState) => {
|
||||
const processKey = 'SPOTIFY_GET_LIBRARY_ALBUMS';
|
||||
dispatch(uiActions.updateProcess(processKey, { notification: false }));
|
||||
|
||||
let libraryItems = [];
|
||||
const fetchLibraryAlbums = (endpoint) => request(dispatch, getState, endpoint)
|
||||
.then((response) => {
|
||||
const processor = getState().ui.processes[processKey];
|
||||
if (processor && processor.status === 'cancelling') {
|
||||
dispatch(uiActions.processCancelled(processKey));
|
||||
dispatch(uiActions.stopLoading('spotify:library:albums'));
|
||||
return;
|
||||
}
|
||||
|
||||
dispatch(uiActions.updateProcess(
|
||||
processKey,
|
||||
{ total: response.total, remaining: response.total - libraryItems.length },
|
||||
));
|
||||
|
||||
const items = response.items.map(
|
||||
(item) => ({
|
||||
...formatAlbum(item),
|
||||
@ -1612,9 +1643,11 @@ export function getLibraryAlbums(forceRefetch) {
|
||||
}),
|
||||
);
|
||||
libraryItems = [...libraryItems, ...items];
|
||||
|
||||
if (response.next) {
|
||||
fetchLibraryAlbums(`${response.next}${forceRefetch ? `&refetch=${Date.now()}` : ''}`);
|
||||
} else {
|
||||
dispatch(uiActions.processFinished(processKey));
|
||||
dispatch(coreActions.itemsLoaded(libraryItems));
|
||||
dispatch(coreActions.libraryLoaded({
|
||||
uri: 'spotify:library:albums',
|
||||
@ -1629,9 +1662,24 @@ export function getLibraryAlbums(forceRefetch) {
|
||||
|
||||
export function getLibraryArtists(forceRefetch) {
|
||||
return (dispatch, getState) => {
|
||||
const processKey = 'SPOTIFY_GET_LIBRARY_ARTISTS';
|
||||
dispatch(uiActions.updateProcess(processKey, { notification: false }));
|
||||
|
||||
let libraryItems = [];
|
||||
const fetchLibraryArtists = (endpoint) => request(dispatch, getState, endpoint)
|
||||
.then((response) => {
|
||||
const processor = getState().ui.processes[processKey];
|
||||
if (processor && processor.status === 'cancelling') {
|
||||
dispatch(uiActions.processCancelled(processKey));
|
||||
dispatch(uiActions.stopLoading('spotify:library:artists'));
|
||||
return;
|
||||
}
|
||||
|
||||
dispatch(uiActions.updateProcess(
|
||||
processKey,
|
||||
{ total: response.artists.total, remaining: response.artists.total - libraryItems.length },
|
||||
));
|
||||
|
||||
const items = response.artists.items.map(
|
||||
(item) => ({
|
||||
...formatArtist(item),
|
||||
@ -1642,6 +1690,7 @@ export function getLibraryArtists(forceRefetch) {
|
||||
if (response.next) {
|
||||
fetchLibraryArtists(`${response.next}${forceRefetch ? `&refetch=${Date.now()}` : ''}`);
|
||||
} else {
|
||||
dispatch(uiActions.processFinished(processKey));
|
||||
dispatch(coreActions.itemsLoaded(libraryItems));
|
||||
dispatch(coreActions.libraryLoaded({
|
||||
uri: 'spotify:library:artists',
|
||||
|
||||
@ -275,31 +275,19 @@ export function stopLoading(keys) {
|
||||
};
|
||||
}
|
||||
|
||||
export function startProcess(key, content, data = {}, description = null) {
|
||||
export function startProcess(key, process) {
|
||||
return {
|
||||
type: 'START_PROCESS',
|
||||
key,
|
||||
data,
|
||||
content,
|
||||
description,
|
||||
process,
|
||||
};
|
||||
}
|
||||
|
||||
export function resumeProcess(key) {
|
||||
return {
|
||||
type: 'RESUME_PROCESS',
|
||||
key,
|
||||
};
|
||||
}
|
||||
|
||||
export function updateProcess(key, content, data = {}, description = null, level = 'info') {
|
||||
export function updateProcess(key, process) {
|
||||
return {
|
||||
type: 'UPDATE_PROCESS',
|
||||
key,
|
||||
content,
|
||||
data,
|
||||
description,
|
||||
level,
|
||||
process,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -182,25 +182,6 @@ const UIMiddleware = (function () {
|
||||
next(action);
|
||||
break;
|
||||
|
||||
case 'START_PROCESS':
|
||||
store.dispatch({
|
||||
type: action.key,
|
||||
data: action.data,
|
||||
});
|
||||
store.dispatch({
|
||||
type: `${action.key}_STARTED`,
|
||||
});
|
||||
next(action);
|
||||
break;
|
||||
|
||||
case 'RESUME_PROCESS':
|
||||
store.dispatch({
|
||||
type: action.key,
|
||||
data: store.getState().ui.processes[action.key].data,
|
||||
});
|
||||
next(action);
|
||||
break;
|
||||
|
||||
case 'PROCESS_CANCELLED':
|
||||
store.dispatch({
|
||||
type: `${action.key}_CANCELLED`,
|
||||
|
||||
@ -135,67 +135,56 @@ export default function reducer(ui = {}, action) {
|
||||
};
|
||||
|
||||
case 'START_PROCESS':
|
||||
case 'UPDATE_PROCESS':
|
||||
var processes = { ...(ui.processes || []) };
|
||||
var last_run = processes[action.key];
|
||||
var status = 'running';
|
||||
if (last_run) {
|
||||
var data = { ...last_run.data, ...action.data };
|
||||
if (action.type === 'UPDATE_PROCESS') status = last_run.status;
|
||||
} else {
|
||||
var { data } = action;
|
||||
}
|
||||
case 'UPDATE_PROCESS': {
|
||||
const processes = { ...(ui.processes || []) };
|
||||
processes[action.key] = {
|
||||
key: action.key,
|
||||
content: action.content,
|
||||
description: action.description,
|
||||
level: action.level,
|
||||
status,
|
||||
data,
|
||||
...processes[action.key] || { notification: true },
|
||||
...(action.type === 'START_PROCESS' ? { status: 'running', remaining: 0, total: 0 } : {}),
|
||||
...action.process,
|
||||
};
|
||||
return { ...ui, processes };
|
||||
}
|
||||
|
||||
case 'RESUME_PROCESS':
|
||||
var processes = { ...(ui.processes ? ui.processes : {}) };
|
||||
if (processes[action.key]) {
|
||||
processes[action.key] = { ...processes[action.key], status: 'running' };
|
||||
}
|
||||
return { ...ui, processes };
|
||||
|
||||
case 'CANCEL_PROCESS':
|
||||
var processes = { ...(ui.processes ? ui.processes : {}) };
|
||||
case 'CANCEL_PROCESS': {
|
||||
const processes = { ...(ui.processes ? ui.processes : {}) };
|
||||
if (processes[action.key]) {
|
||||
processes[action.key] = { ...processes[action.key], status: 'cancelling' };
|
||||
}
|
||||
return { ...ui, processes };
|
||||
}
|
||||
|
||||
case 'PROCESS_CANCELLED':
|
||||
case 'PROCESS_CANCELLED': {
|
||||
var processes = { ...(ui.processes ? ui.processes : {}) };
|
||||
if (processes[action.key]) {
|
||||
processes[action.key] = { ...processes[action.key], status: 'cancelled' };
|
||||
}
|
||||
return { ...ui, processes };
|
||||
}
|
||||
|
||||
case 'PROCESS_FINISHED':
|
||||
case 'PROCESS_FINISHED': {
|
||||
var processes = { ...(ui.processes ? ui.processes : {}) };
|
||||
if (processes[action.key]) {
|
||||
processes[action.key] = { ...processes[action.key], status: 'finished' };
|
||||
}
|
||||
return { ...ui, processes };
|
||||
}
|
||||
|
||||
case 'CLOSE_PROCESS':
|
||||
case 'CLOSE_PROCESS': {
|
||||
var processes = { ...(ui.processes ? ui.processes : {}) };
|
||||
if (processes[action.key]) {
|
||||
processes[action.key] = { ...processes[action.key], closing: true };
|
||||
}
|
||||
return { ...ui, processes };
|
||||
}
|
||||
|
||||
case 'REMOVE_PROCESS':
|
||||
case 'REMOVE_PROCESS': {
|
||||
var processes = { ...(ui.processes ? ui.processes : {}) };
|
||||
if (processes[action.key]) {
|
||||
processes[action.key] = { ...processes[action.key], status: 'completed', closing: false };
|
||||
}
|
||||
return { ...ui, processes };
|
||||
}
|
||||
|
||||
case 'SUPPRESS_BROADCAST':
|
||||
return { ...ui, suppressed_broadcasts: [...(ui.suppressed_broadcasts || []), action.key] };
|
||||
|
||||
@ -5,6 +5,7 @@ import { isLoading } from './helpers';
|
||||
const getItem = (state, uri) => state.core.items[uri];
|
||||
const getItems = (state) => state.core.items;
|
||||
const getLoadQueue = (state) => state.ui.load_queue;
|
||||
const getProcesses = (state) => state.ui.processes;
|
||||
const getLibrary = (state, uri) => state.core.libraries[uri];
|
||||
const getLibraries = (state) => state.core.libraries;
|
||||
const getSearchResults = (state) => state.core.search_results;
|
||||
@ -52,6 +53,21 @@ const makeSearchResultsSelector = (term, type) => createSelector(
|
||||
},
|
||||
);
|
||||
|
||||
const makeProcessProgressSelector = (keys) => createSelector(
|
||||
[getProcesses],
|
||||
(processes) => {
|
||||
const selectedProcesses = keys.map((key) => processes[key] || {});
|
||||
let total = 0;
|
||||
let remaining = 0;
|
||||
selectedProcesses.forEach((process) => {
|
||||
if (process.total) total += process.total;
|
||||
if (process.remaining) remaining += process.remaining;
|
||||
});
|
||||
console.log({ total, remaining })
|
||||
return total && remaining ? ((total - remaining) / total).toFixed(4) : 0;
|
||||
},
|
||||
);
|
||||
|
||||
export {
|
||||
getItem,
|
||||
getLibrary,
|
||||
@ -60,5 +76,6 @@ export {
|
||||
makeLibrarySelector,
|
||||
makeLoadingSelector,
|
||||
makeSearchResultsSelector,
|
||||
makeProcessProgressSelector,
|
||||
queueHistorySelector,
|
||||
};
|
||||
|
||||
@ -21,6 +21,7 @@ import Loader from '../../components/Loader';
|
||||
import {
|
||||
makeLibrarySelector,
|
||||
makeLoadingSelector,
|
||||
makeProcessProgressSelector,
|
||||
} from '../../util/selectors';
|
||||
|
||||
class LibraryAlbums extends React.Component {
|
||||
@ -175,6 +176,7 @@ class LibraryAlbums extends React.Component {
|
||||
sort_reverse,
|
||||
view,
|
||||
loading,
|
||||
loading_progress,
|
||||
} = this.props;
|
||||
const {
|
||||
limit,
|
||||
@ -183,7 +185,8 @@ class LibraryAlbums extends React.Component {
|
||||
let { albums } = this.props;
|
||||
|
||||
if (loading) {
|
||||
return <Loader body loading />;
|
||||
console.log(loading_progress);
|
||||
return <Loader body loading progress={loading_progress} />
|
||||
}
|
||||
|
||||
if (sort) {
|
||||
@ -376,9 +379,15 @@ const mapStateToProps = (state) => {
|
||||
if (source === 'all' || source === 'spotify') libraryUris.push('spotify:library:albums');
|
||||
if (source === 'all' || source === 'google') libraryUris.push('google:library:albums');
|
||||
const librarySelector = makeLibrarySelector(libraryUris);
|
||||
const processProgressSelector = makeProcessProgressSelector([
|
||||
'MOPIDY_GET_LIBRARY_ALBUMS',
|
||||
'SPOTIFY_GET_LIBRARY_ALBUMS',
|
||||
'GOOGLE_GET_LIBRARY_ALBUMS',
|
||||
]);
|
||||
|
||||
return {
|
||||
loading: loadingSelector(state),
|
||||
loading_progress: processProgressSelector(state),
|
||||
mopidy_uri_schemes: state.mopidy.uri_schemes,
|
||||
albums: librarySelector(state),
|
||||
google_available: (state.mopidy.uri_schemes && state.mopidy.uri_schemes.includes('gmusic:')),
|
||||
|
||||
@ -18,6 +18,7 @@ import Loader from '../../components/Loader';
|
||||
import {
|
||||
makeLibrarySelector,
|
||||
makeLoadingSelector,
|
||||
makeProcessProgressSelector,
|
||||
} from '../../util/selectors';
|
||||
|
||||
class LibraryArtists extends React.Component {
|
||||
@ -151,6 +152,7 @@ class LibraryArtists extends React.Component {
|
||||
sort_reverse,
|
||||
view,
|
||||
loading,
|
||||
loading_progress,
|
||||
} = this.props;
|
||||
const {
|
||||
limit,
|
||||
@ -159,7 +161,7 @@ class LibraryArtists extends React.Component {
|
||||
let { artists } = this.props;
|
||||
|
||||
if (loading) {
|
||||
return <Loader body loading />;
|
||||
return <Loader body loading progress={loading_progress} />
|
||||
}
|
||||
|
||||
if (sort) {
|
||||
@ -335,8 +337,14 @@ const mapStateToProps = (state) => {
|
||||
if (source === 'all' || source === 'spotify') libraryUris.push('spotify:library:artists');
|
||||
if (source === 'all' || source === 'google') libraryUris.push('google:library:artists');
|
||||
const librarySelector = makeLibrarySelector(libraryUris);
|
||||
const processProgressSelector = makeProcessProgressSelector([
|
||||
'MOPIDY_GET_LIBRARY_ARTISTS',
|
||||
'SPOTIFY_GET_LIBRARY_ARTISTS',
|
||||
'GOOGLE_GET_LIBRARY_ARTISTS',
|
||||
]);
|
||||
|
||||
return {
|
||||
loading_progress: processProgressSelector(state),
|
||||
mopidy_uri_schemes: state.mopidy.uri_schemes,
|
||||
google_available: (state.mopidy.uri_schemes && state.mopidy.uri_schemes.includes('gmusic:')),
|
||||
spotify_available: (state.spotify.access_token),
|
||||
|
||||
Reference in New Issue
Block a user