mirror of
https://github.com/captbaritone/webamp.git
synced 2026-07-22 17:47:16 +00:00
Revert "Make hotkeys a function not a singleton class that has side effects when you construct it"
This reverts commit 87ca43ba45.
This commit is contained in:
parent
73de91abc0
commit
9b8cb032a6
2 changed files with 5 additions and 12 deletions
|
|
@ -21,7 +21,7 @@ import { TOGGLE_TIME_MODE, TOGGLE_LLAMA_MODE } from "./actionTypes";
|
|||
import { arraysAreEqual } from "./utils";
|
||||
import { Dispatch } from "./types";
|
||||
|
||||
export function bindHotkeys(dispatch: Dispatch): () => void {
|
||||
export default function(dispatch: Dispatch) {
|
||||
let keylog: number[] = [];
|
||||
const trigger = [
|
||||
78, // N
|
||||
|
|
@ -33,8 +33,7 @@ export function bindHotkeys(dispatch: Dispatch): () => void {
|
|||
70, // F
|
||||
84 // T
|
||||
];
|
||||
|
||||
const listener = (e: KeyboardEvent) => {
|
||||
document.addEventListener("keydown", e => {
|
||||
if (e.ctrlKey) {
|
||||
switch (e.keyCode) {
|
||||
case 68: // CTRL+D
|
||||
|
|
@ -143,10 +142,5 @@ export function bindHotkeys(dispatch: Dispatch): () => void {
|
|||
dispatch({ type: TOGGLE_LLAMA_MODE });
|
||||
}
|
||||
}
|
||||
};
|
||||
document.addEventListener("keydown", listener);
|
||||
|
||||
return () => {
|
||||
document.removeEventListener("keydown", listener);
|
||||
};
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import { Provider } from "react-redux";
|
|||
|
||||
import getStore from "./store";
|
||||
import App from "./components/App";
|
||||
import { bindHotkeys } from "./hotkeys";
|
||||
import Hotkeys from "./hotkeys";
|
||||
import Media from "./media";
|
||||
import * as Selectors from "./selectors";
|
||||
import {
|
||||
|
|
@ -65,7 +65,6 @@ class Winamp {
|
|||
}
|
||||
|
||||
constructor(options) {
|
||||
this._subscriptions = [];
|
||||
this._actionEmitter = new Emitter();
|
||||
this.options = options;
|
||||
const {
|
||||
|
|
@ -162,7 +161,7 @@ class Winamp {
|
|||
}
|
||||
|
||||
if (enableHotkeys) {
|
||||
this._subscriptions.push(bindHotkeys(this.store.dispatch));
|
||||
new Hotkeys(this.store.dispatch);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue