mirror of
https://github.com/captbaritone/webamp.git
synced 2026-07-20 01:54:01 +00:00
Add optional accept argument
This commit is contained in:
parent
512f123cfa
commit
1f329174ce
3 changed files with 7 additions and 4 deletions
|
|
@ -339,9 +339,9 @@ export function setSkinFromUrl(url) {
|
|||
};
|
||||
}
|
||||
|
||||
export function openFileDialog() {
|
||||
export function openFileDialog(accept) {
|
||||
return async dispatch => {
|
||||
const fileReferences = await promptForFileReferences();
|
||||
const fileReferences = await promptForFileReferences(accept);
|
||||
dispatch(loadFilesFromReferences(fileReferences));
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ const MainContextMenu = props => (
|
|||
<Hr />
|
||||
<Node onClick={props.openFileDialog} label="Play File..." />
|
||||
<Parent label="Skins">
|
||||
<Node onClick={props.openFileDialog} label="Load Skin..." />
|
||||
<Node onClick={props.openFileDialog.bind(null, '.zip, .wsz')} label="Load Skin..." />
|
||||
{!!props.avaliableSkins.length && <Hr />}
|
||||
{props.avaliableSkins.map(skin => (
|
||||
<Node
|
||||
|
|
|
|||
|
|
@ -28,11 +28,14 @@ export async function genArrayBufferFromUrl(url) {
|
|||
});
|
||||
}
|
||||
|
||||
export async function promptForFileReferences() {
|
||||
export async function promptForFileReferences(accept) {
|
||||
return new Promise(resolve => {
|
||||
// Does this represent a memory leak somehow?
|
||||
// Can this fail? Do we ever reject?
|
||||
const fileInput = document.createElement("input");
|
||||
if (accept) {
|
||||
fileInput.setAttribute('accept', accept)
|
||||
}
|
||||
fileInput.type = "file";
|
||||
fileInput.multiple = true;
|
||||
// Not entirely sure why this is needed, since the input
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue