mirror of
https://github.com/captbaritone/webamp.git
synced 2026-07-21 09:09:01 +00:00
Type MainContextMenu
This commit is contained in:
parent
15b3fa7c74
commit
58dafaffa4
3 changed files with 40 additions and 12 deletions
|
|
@ -65,6 +65,7 @@ export const Parent = ({ children, label }: ParentProps) => (
|
|||
interface LinkNodeProps {
|
||||
label: string;
|
||||
href: string;
|
||||
target?: string;
|
||||
}
|
||||
|
||||
export const LinkNode = (props: LinkNodeProps) => (
|
||||
|
|
|
|||
|
|
@ -12,8 +12,35 @@ import { Hr, Node, Parent, LinkNode } from "../ContextMenu";
|
|||
import PlaybackContextMenu from "../PlaybackContextMenu";
|
||||
import OptionsContextMenu from "../OptionsContextMenu";
|
||||
import SkinsContextMenu from "../SkinsContextMenu";
|
||||
import {
|
||||
AppState,
|
||||
Dispatch,
|
||||
Track,
|
||||
WindowId,
|
||||
FilePicker,
|
||||
LoadStyle
|
||||
} from "../../types";
|
||||
import { WebampWindow } from "../../reducers/windows";
|
||||
|
||||
const MainContextMenu = props => (
|
||||
interface StateProps {
|
||||
networkConnected: boolean;
|
||||
genWindows: { [windowId: string]: WebampWindow };
|
||||
}
|
||||
|
||||
interface DispatchProps {
|
||||
close(): void;
|
||||
openMediaFileDialog(): void;
|
||||
loadMediaFiles(tracks: Track[], loadStyle: LoadStyle): void;
|
||||
toggleGenWindow(windowId: WindowId): void;
|
||||
}
|
||||
|
||||
interface OwnProps {
|
||||
filePickers: FilePicker[];
|
||||
}
|
||||
|
||||
type Props = StateProps & DispatchProps & OwnProps;
|
||||
|
||||
const MainContextMenu = (props: Props) => (
|
||||
<React.Fragment>
|
||||
<LinkNode
|
||||
href="https://github.com/captbaritone/webamp"
|
||||
|
|
@ -36,7 +63,7 @@ const MainContextMenu = props => (
|
|||
} catch (e) {
|
||||
console.error("Error loading from file picker", e);
|
||||
}
|
||||
props.loadMediaFiles(files, LOAD_STYLE.PLAY);
|
||||
props.loadMediaFiles(files || [], LOAD_STYLE.PLAY);
|
||||
}}
|
||||
label={picker.contextMenuName}
|
||||
/>
|
||||
|
|
@ -67,16 +94,19 @@ const MainContextMenu = props => (
|
|||
</React.Fragment>
|
||||
);
|
||||
|
||||
const mapStateToProps = state => ({
|
||||
const mapStateToProps = (state: AppState): StateProps => ({
|
||||
networkConnected: state.network.connected,
|
||||
genWindows: getGenWindows(state)
|
||||
});
|
||||
|
||||
const mapDispatchToProps = {
|
||||
close,
|
||||
openMediaFileDialog,
|
||||
loadMediaFiles,
|
||||
toggleGenWindow: toggleWindow
|
||||
const mapDispatchToProps = (dispatch: Dispatch): DispatchProps => {
|
||||
return {
|
||||
close: () => dispatch(close()),
|
||||
openMediaFileDialog: () => dispatch(openMediaFileDialog()),
|
||||
loadMediaFiles: (tracks: Track[], loadStyle: LoadStyle) =>
|
||||
dispatch(loadMediaFiles(tracks, loadStyle)),
|
||||
toggleGenWindow: (windowId: WindowId) => dispatch(toggleWindow(windowId))
|
||||
};
|
||||
};
|
||||
|
||||
export default connect(
|
||||
|
|
@ -121,10 +121,7 @@ export class MainWindow extends React.Component<Props> {
|
|||
bottom
|
||||
handle={<ClickedDiv id="option" title="Winamp Menu" />}
|
||||
>
|
||||
<MainContextMenu
|
||||
// @ts-ignore MainContextMenu is not typed yet
|
||||
filePickers={filePickers}
|
||||
/>
|
||||
<MainContextMenu filePickers={filePickers} />
|
||||
</ContextMenuTarget>
|
||||
{mainShade && <MiniTime />}
|
||||
<Minimize />
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue