2019-02-10 19:51:33 +13:00
|
|
|
import React from 'react';
|
2019-01-16 16:46:40 +13:00
|
|
|
import { connect } from 'react-redux';
|
|
|
|
|
import { bindActionCreators } from 'redux';
|
|
|
|
|
import Header from '../../components/Header';
|
2021-02-27 21:45:00 +13:00
|
|
|
import { Grid } from '../../components/Grid';
|
2021-02-01 20:41:49 +13:00
|
|
|
import Loader from '../../components/Loader';
|
2019-01-16 16:46:40 +13:00
|
|
|
import Icon from '../../components/Icon';
|
|
|
|
|
import * as uiActions from '../../services/ui/actions';
|
|
|
|
|
import * as mopidyActions from '../../services/mopidy/actions';
|
2021-01-23 16:24:07 +13:00
|
|
|
import { formatImages, encodeUri } from '../../util/format';
|
2020-07-19 20:41:14 +12:00
|
|
|
import { I18n, i18n } from '../../locale';
|
2021-02-01 20:41:49 +13:00
|
|
|
import { makeLoadingSelector } from '../../util/selectors';
|
2017-07-07 09:59:16 +12:00
|
|
|
|
2021-11-28 19:52:12 +13:00
|
|
|
class Browse extends React.Component {
|
2019-09-05 15:36:11 +12:00
|
|
|
componentDidMount() {
|
|
|
|
|
this.loadDirectory();
|
2020-07-19 20:41:14 +12:00
|
|
|
this.props.uiActions.setWindowTitle(i18n('library.browse.title'));
|
2019-09-05 15:36:11 +12:00
|
|
|
}
|
|
|
|
|
|
2020-08-12 08:06:24 +12:00
|
|
|
loadDirectory = () => {
|
|
|
|
|
const {
|
|
|
|
|
mopidyActions: {
|
|
|
|
|
getDirectory,
|
|
|
|
|
},
|
|
|
|
|
} = this.props;
|
|
|
|
|
|
|
|
|
|
getDirectory(null);
|
2019-09-05 15:36:11 +12:00
|
|
|
}
|
|
|
|
|
|
2021-02-01 20:41:49 +13:00
|
|
|
render = () => {
|
|
|
|
|
const {
|
|
|
|
|
loading,
|
|
|
|
|
directory,
|
|
|
|
|
} = this.props;
|
|
|
|
|
|
|
|
|
|
if (!directory) {
|
|
|
|
|
if (loading) {
|
|
|
|
|
return <Loader body loading />;
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-05 15:36:11 +12:00
|
|
|
const grid_items = [];
|
2021-02-01 20:41:49 +13:00
|
|
|
if (directory.subdirectories) {
|
|
|
|
|
for (const subdirectory of directory.subdirectories) {
|
2019-09-05 15:36:11 +12:00
|
|
|
switch (subdirectory.name) {
|
|
|
|
|
case 'Dirble':
|
|
|
|
|
subdirectory.icons = ['/iris/assets/backgrounds/browse-dirble.jpg'];
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'Files':
|
|
|
|
|
subdirectory.icons = ['/iris/assets/backgrounds/browse-folders.jpg'];
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'Local media':
|
|
|
|
|
subdirectory.icons = ['/iris/assets/backgrounds/browse-folders.jpg'];
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'Spotify':
|
|
|
|
|
case 'Spotify Browse':
|
|
|
|
|
case 'Spotify Web Browse':
|
|
|
|
|
subdirectory.icons = ['/iris/assets/backgrounds/browse-spotify.jpg'];
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'Spotify Tunigo':
|
|
|
|
|
case 'Tunigo':
|
|
|
|
|
subdirectory.icons = ['/iris/assets/backgrounds/browse-tunigo.jpg'];
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'TuneIn':
|
|
|
|
|
subdirectory.icons = ['/iris/assets/backgrounds/browse-tunein.jpg'];
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'SoundCloud':
|
|
|
|
|
subdirectory.icons = ['/iris/assets/backgrounds/browse-soundcloud.jpg'];
|
|
|
|
|
break;
|
|
|
|
|
|
2020-07-05 21:16:31 +02:00
|
|
|
case 'Mixcloud':
|
|
|
|
|
subdirectory.icons = ['/iris/assets/backgrounds/browse-mixcloud.jpg'];
|
|
|
|
|
break;
|
|
|
|
|
|
2019-09-05 15:36:11 +12:00
|
|
|
case 'iTunes Store: Podcasts':
|
|
|
|
|
subdirectory.icons = ['/iris/assets/backgrounds/browse-itunes.jpg'];
|
|
|
|
|
break;
|
|
|
|
|
|
2022-05-27 18:35:07 +01:00
|
|
|
case 'SomaFM':
|
2019-09-05 15:36:11 +12:00
|
|
|
subdirectory.icons = ['/iris/assets/backgrounds/browse-somafm.jpg'];
|
|
|
|
|
break;
|
2022-05-27 18:35:07 +01:00
|
|
|
|
|
|
|
|
case 'Jellyfin':
|
|
|
|
|
subdirectory.icons = ['/iris/assets/backgrounds/browse-jellyfin.jpg'];
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'Podcasts':
|
|
|
|
|
subdirectory.icons = ['/iris/assets/backgrounds/browse-podcasts.jpg'];
|
|
|
|
|
break;
|
2019-09-05 15:36:11 +12:00
|
|
|
|
2020-04-30 15:45:55 +12:00
|
|
|
case 'Tidal':
|
|
|
|
|
subdirectory.icons = ['/iris/assets/backgrounds/browse-tidal.jpg'];
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'Google':
|
|
|
|
|
case 'Google Play':
|
|
|
|
|
case 'Google Play Music':
|
|
|
|
|
subdirectory.icons = ['/iris/assets/backgrounds/browse-google.jpg'];
|
|
|
|
|
break;
|
|
|
|
|
|
2021-04-28 21:12:28 +12:00
|
|
|
case 'YouTube Music':
|
|
|
|
|
subdirectory.icons = ['/iris/assets/backgrounds/browse-youtube.jpg'];
|
|
|
|
|
break;
|
|
|
|
|
|
2019-09-05 15:36:11 +12:00
|
|
|
default:
|
|
|
|
|
subdirectory.icons = ['/iris/assets/backgrounds/browse-default.jpg'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
grid_items.push({
|
|
|
|
|
name: subdirectory.name,
|
2021-02-15 21:01:39 +13:00
|
|
|
link: `/library/browse/${encodeURIComponent(subdirectory.name)}/${encodeUri(subdirectory.uri)}`,
|
2020-03-03 16:39:37 +13:00
|
|
|
icons: formatImages(subdirectory.icons),
|
2019-09-05 15:36:11 +12:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div className="view library-local-view">
|
|
|
|
|
<Header>
|
|
|
|
|
<Icon name="folder" type="material" />
|
2021-02-01 20:41:49 +13:00
|
|
|
<I18n path="library.browse.title" />
|
2019-09-05 15:36:11 +12:00
|
|
|
</Header>
|
|
|
|
|
<section className="content-wrapper">
|
|
|
|
|
<div className="grid grid--tiles">
|
2021-04-28 21:12:28 +12:00
|
|
|
<Grid items={grid_items} sourceIcon={false} />
|
2019-09-05 15:36:11 +12:00
|
|
|
</div>
|
|
|
|
|
</section>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
2017-07-07 09:59:16 +12:00
|
|
|
}
|
|
|
|
|
|
2021-03-05 23:10:41 +13:00
|
|
|
const loadingSelector = makeLoadingSelector(['(.*)mopidy_library.browse(.*)']);
|
2021-02-01 20:41:49 +13:00
|
|
|
const mapStateToProps = (state) => {
|
|
|
|
|
const {
|
|
|
|
|
mopidy: {
|
|
|
|
|
directory: _directory = {},
|
|
|
|
|
},
|
|
|
|
|
ui: {
|
|
|
|
|
library_directory_view: view,
|
|
|
|
|
},
|
|
|
|
|
} = state;
|
|
|
|
|
const directory = _directory && _directory.uri === null ? _directory : null;
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
loading: loadingSelector(state),
|
|
|
|
|
directory,
|
|
|
|
|
view,
|
|
|
|
|
};
|
|
|
|
|
};
|
2017-07-07 09:59:16 +12:00
|
|
|
|
2019-09-05 15:36:11 +12:00
|
|
|
const mapDispatchToProps = (dispatch) => ({
|
|
|
|
|
uiActions: bindActionCreators(uiActions, dispatch),
|
|
|
|
|
mopidyActions: bindActionCreators(mopidyActions, dispatch),
|
|
|
|
|
});
|
2017-07-07 09:59:16 +12:00
|
|
|
|
2021-11-28 19:52:12 +13:00
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(Browse);
|