import React from "react"; import * as Actions from "../../actionCreators"; import * as Selectors from "../../selectors"; import { LOAD_STYLE } from "../../constants"; import { Hr, Node, Parent, LinkNode } from "../ContextMenu"; import PlaybackContextMenu from "../PlaybackContextMenu"; import OptionsContextMenu from "../OptionsContextMenu"; import SkinsContextMenu from "../SkinsContextMenu"; import { FilePicker } from "../../types"; import { useTypedSelector, useActionCreator } from "../../hooks"; interface Props { filePickers: FilePicker[]; } const MainContextMenu = React.memo((props: Props) => { const networkConnected = useTypedSelector(Selectors.getNetworkConnected); const genWindows = useTypedSelector(Selectors.getGenWindows); const close = useActionCreator(Actions.close); const openMediaFileDialog = useActionCreator(Actions.openMediaFileDialog); const loadMediaFiles = useActionCreator(Actions.loadMediaFiles); const toggleWindow = useActionCreator(Actions.toggleWindow); return (
{props.filePickers && props.filePickers.map( (picker, i) => (networkConnected || !picker.requiresNetwork) && ( { let files; try { files = await picker.filePicker(); } catch (e) { console.error("Error loading from file picker", e); } loadMediaFiles(files || [], LOAD_STYLE.PLAY); }} label={picker.contextMenuName} /> ) )}
{Object.keys(genWindows).map(i => ( toggleWindow(i)} hotkey={genWindows[i].hotkey} /> ))}


); }); export default MainContextMenu;