mirror of
https://github.com/captbaritone/webamp.git
synced 2026-07-21 09:09:01 +00:00
35 lines
1.1 KiB
JavaScript
35 lines
1.1 KiB
JavaScript
import React from "react";
|
|
import { connect } from "react-redux";
|
|
import { addTracksFromReferences } from "../../actionCreators";
|
|
import { promptForFileReferences } from "../../fileUtils";
|
|
import PlaylistMenu from "./PlaylistMenu";
|
|
|
|
/* eslint-disable no-alert */
|
|
|
|
const AddMenu = ({ nextIndex, addFilesAtIndex }) => (
|
|
<PlaylistMenu id="playlist-add-menu">
|
|
<div
|
|
className="add-url"
|
|
onClick={() => alert("Not supported in Winamp2-js")}
|
|
/>
|
|
<div
|
|
className="add-dir"
|
|
onClick={() => alert("Not supported in Winamp2-js")}
|
|
/>
|
|
<div className="add-file" onClick={() => addFilesAtIndex(nextIndex)} />
|
|
</PlaylistMenu>
|
|
);
|
|
|
|
const mapStateToProps = state => ({
|
|
nextIndex: state.playlist.trackOrder.length
|
|
});
|
|
|
|
const mapDispatchToProps = dispatch => ({
|
|
addFilesAtIndex: async nextIndex => {
|
|
// TODO: This seems to fail sometimes.
|
|
const fileReferences = await promptForFileReferences();
|
|
dispatch(addTracksFromReferences(fileReferences, false, nextIndex));
|
|
}
|
|
});
|
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(AddMenu);
|