mirror of
https://github.com/captbaritone/webamp.git
synced 2026-08-03 07:23:55 +00:00
Avoid uneeded renders
This commit is contained in:
parent
c00cb44b8d
commit
e89aa26612
2 changed files with 42 additions and 28 deletions
|
|
@ -75,6 +75,10 @@ class TrackList extends React.Component<DispatchProps & StateProps> {
|
|||
window.addEventListener("mousemove", handleMouseMove);
|
||||
};
|
||||
|
||||
_handleRef = (node: HTMLDivElement | null) => {
|
||||
this._node = node;
|
||||
};
|
||||
|
||||
render() {
|
||||
const { tracks, offset } = this.props;
|
||||
const maxTrackNumberLength = getNumberLength(this.props.numberOfTracks);
|
||||
|
|
@ -82,9 +86,7 @@ class TrackList extends React.Component<DispatchProps & StateProps> {
|
|||
(i + 1 + offset).toString().padStart(maxTrackNumberLength, "\u00A0");
|
||||
return (
|
||||
<div
|
||||
ref={node => {
|
||||
this._node = node;
|
||||
}}
|
||||
ref={this._handleRef}
|
||||
className="playlist-tracks"
|
||||
style={{ height: "100%" }}
|
||||
onClick={this.props.selectZero}
|
||||
|
|
|
|||
|
|
@ -401,22 +401,6 @@ function getWPixelSize(w: WebampWindow, doubled: boolean) {
|
|||
};
|
||||
}
|
||||
|
||||
export function getWindowSize(state: AppState) {
|
||||
return (windowId: WindowId) => state.windows.genWindows[windowId].size;
|
||||
}
|
||||
|
||||
export function getWindowOpen(state: AppState) {
|
||||
return (windowId: WindowId) => state.windows.genWindows[windowId].open;
|
||||
}
|
||||
|
||||
export function getWindowShade(state: AppState) {
|
||||
return (windowId: WindowId) => state.windows.genWindows[windowId].shade;
|
||||
}
|
||||
|
||||
export function getWindowHidden(state: AppState) {
|
||||
return (windowId: WindowId) => state.windows.genWindows[windowId].hidden;
|
||||
}
|
||||
|
||||
export function getFocusedWindow(state: AppState): WindowId | null {
|
||||
return state.windows.focused;
|
||||
}
|
||||
|
|
@ -433,6 +417,34 @@ export const getGenWindows = (state: AppState) => {
|
|||
return state.windows.genWindows;
|
||||
};
|
||||
|
||||
export const getWindowOpen = createSelector(
|
||||
getGenWindows,
|
||||
genWindows => {
|
||||
return (windowId: WindowId) => genWindows[windowId].open;
|
||||
}
|
||||
);
|
||||
|
||||
export const getWindowHidden = createSelector(
|
||||
getGenWindows,
|
||||
genWindows => {
|
||||
return (windowId: WindowId) => genWindows[windowId].hidden;
|
||||
}
|
||||
);
|
||||
|
||||
export const getWindowShade = createSelector(
|
||||
getGenWindows,
|
||||
genWindows => {
|
||||
return (windowId: WindowId) => genWindows[windowId].shade;
|
||||
}
|
||||
);
|
||||
|
||||
export const getWindowSize = createSelector(
|
||||
getGenWindows,
|
||||
genWindows => {
|
||||
return (windowId: WindowId) => genWindows[windowId].size;
|
||||
}
|
||||
);
|
||||
|
||||
export const getWindowPositions = createSelector(
|
||||
getGenWindows,
|
||||
(windows): WindowPositions => Utils.objectMap(windows, w => w.position)
|
||||
|
|
@ -474,16 +486,16 @@ export const getWindowGraph = createSelector(
|
|||
generateGraph
|
||||
);
|
||||
|
||||
const defaultPlaylistStyle = {
|
||||
normal: "#00FF00",
|
||||
current: "#FFFFFF",
|
||||
normalbg: "#000000",
|
||||
selectedbg: "#0000C6",
|
||||
font: "Arial",
|
||||
};
|
||||
|
||||
export const getSkinPlaylistStyle = (state: AppState): PlaylistStyle => {
|
||||
return (
|
||||
state.display.skinPlaylistStyle || {
|
||||
normal: "#00FF00",
|
||||
current: "#FFFFFF",
|
||||
normalbg: "#000000",
|
||||
selectedbg: "#0000C6",
|
||||
font: "Arial",
|
||||
}
|
||||
);
|
||||
return state.display.skinPlaylistStyle || defaultPlaylistStyle;
|
||||
};
|
||||
|
||||
export const getSkinGenExColors = (state: AppState) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue