Skip to content

Commit 024e86e

Browse files
authored
fix: stop broken background images from displaying (@mattlau1) (monkeytypegame#6526)
### Description If the specified background image is invalid, then we can hide it using `this.style.display='none'`, which will also hide the default white outline and broken image icon Also fixed a typo in the notification for it (temporairly -> temporarily) Tested fix by entering invalid custom background URL in settings (i.e. `https://tehtuhgsfdsfjsdg.com/test.jpg`) Closes monkeytypegame#6524 <!-- the issue(s) your PR resolves if any (delete if that is not the case) --> <!-- please also reference any issues and or PRs related to your pull request --> <!-- Also remove it if you are not following any issues. --> <!-- pro tip: you can mention an issue, PR, or discussion on GitHub by referencing its hash number e.g: [monkeytypegame#1234](monkeytypegame#1234) --> <!-- pro tip: you can press . (dot or period) in the code tab of any GitHub repo to get access to GitHub's VS Code web editor Enjoy! :) --> Thanks!! :)
1 parent c7ac9ad commit 024e86e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

frontend/src/ts/controllers/theme-controller.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ function applyCustomBackground(): void {
357357
img.setAttribute("src", Config.customBackground);
358358
img.setAttribute(
359359
"onError",
360-
"javascript:window.dispatchEvent(new Event('customBackgroundFailed'))"
360+
"javascript:this.style.display='none'; window.dispatchEvent(new Event('customBackgroundFailed'))"
361361
);
362362
container?.replaceChildren(img);
363363

@@ -444,7 +444,7 @@ ConfigEvent.subscribe(async (eventKey, eventValue, nosave) => {
444444

445445
window.addEventListener("customBackgroundFailed", () => {
446446
Notifications.add(
447-
"Custom background link is either temporairly unavailable or expired. Please make sure the URL is correct or change it",
447+
"Custom background link is either temporarily unavailable or expired. Please make sure the URL is correct or change it",
448448
0,
449449
{ duration: 5 }
450450
);

0 commit comments

Comments
 (0)