mirror of
https://github.com/captbaritone/webamp.git
synced 2026-01-23 18:25:30 +00:00
42 lines
1.1 KiB
TypeScript
42 lines
1.1 KiB
TypeScript
import { FilePicker } from "../../js/types";
|
|
|
|
interface DropboxFile {
|
|
link: string;
|
|
name: string;
|
|
}
|
|
|
|
// Requires Dropbox's Chooser to be loaded on the page
|
|
function genAudioFileUrlsFromDropbox(): Promise<DropboxFile[]> {
|
|
return new Promise((resolve, reject) => {
|
|
// @ts-ignore
|
|
if (window.Dropbox == null) {
|
|
reject();
|
|
}
|
|
// @ts-ignore
|
|
window.Dropbox.choose({
|
|
success: resolve,
|
|
error: reject,
|
|
linkType: "direct",
|
|
folderselect: false,
|
|
multiselect: true,
|
|
extensions: ["video", "audio"],
|
|
});
|
|
});
|
|
}
|
|
const dropboxFilePicker: FilePicker = {
|
|
contextMenuName: "Dropbox...",
|
|
filePicker: async () => {
|
|
alert(
|
|
`Dropbox integration is currently disabled. See https://github.com/captbaritone/webamp/issues/750 for more information.`
|
|
);
|
|
// https://github.com/captbaritone/webamp/issues/750
|
|
const files = await genAudioFileUrlsFromDropbox();
|
|
return files.map(file => ({
|
|
url: file.link,
|
|
defaultName: file.name,
|
|
}));
|
|
},
|
|
requiresNetwork: true,
|
|
};
|
|
|
|
export default dropboxFilePicker;
|