Handle case where EQ images are missing

This commit is contained in:
Jordan Eldredge 2019-11-14 22:20:43 -08:00
parent 51f548faea
commit 2e83920ca1
2 changed files with 15 additions and 8 deletions

View file

@ -49,11 +49,12 @@ class EqGraph extends React.Component {
}
async createColorPattern(lineColorsImagePromise) {
const lineColorsImage = await lineColorsImagePromise;
if (lineColorsImage == null) {
return;
}
this.setState({
colorPattern: this.canvasCtx.createPattern(
await lineColorsImagePromise,
"repeat-x"
),
colorPattern: this.canvasCtx.createPattern(lineColorsImage, "repeat-x"),
});
}

View file

@ -721,24 +721,30 @@ export function getRandomizePresets(state: AppState): boolean {
return state.milkdrop.randomize;
}
export function getPreampLineUrl(state: AppState): string {
export function getPreampLineUrl(state: AppState): string | null {
return state.display.skinImages.EQ_PREAMP_LINE;
}
export function getLineColorsUrl(state: AppState): string {
export function getLineColorsUrl(state: AppState): string | null {
return state.display.skinImages.EQ_GRAPH_LINE_COLORS;
}
export const getPreampLineImage = createSelector(
getPreampLineUrl,
async (url): Promise<HTMLImageElement> => {
async (url): Promise<HTMLImageElement | null> => {
if (url == null) {
return null;
}
return Utils.imgFromUrl(url);
}
);
export const getLineColorsImage = createSelector(
getLineColorsUrl,
async (url): Promise<HTMLImageElement> => {
async (url): Promise<HTMLImageElement | null> => {
if (url == null) {
return null;
}
return Utils.imgFromUrl(url);
}
);