From 7184f11baa3d00969adacd3063597d43b40da64a Mon Sep 17 00:00:00 2001 From: uwaa Date: Mon, 13 Jan 2025 02:12:23 +0000 Subject: [PATCH] fix pleroma FE crash cycling --- rot.js | 92 +++++++++++++++++++++++++++++++--------------------------- 1 file changed, 50 insertions(+), 42 deletions(-) diff --git a/rot.js b/rot.js index c04f7e1..00734c7 100644 --- a/rot.js +++ b/rot.js @@ -71,7 +71,11 @@ function setImage(url) { if (url) { console.log("Setting background: " + url); - document.getElementById("app-loaded").style.setProperty("--body-background-image", "url(" + url + ")"); + let apploaded = document.getElementById("app-loaded"); + if (apploaded) + apploaded.style.setProperty("--body-background-image", "url(" + url + ")"); + else + console.log("Couldn't set background, app not yet loaded"); } } @@ -192,55 +196,59 @@ //Switch-based monkey patching router bullshit let lastPath = null; function updateRot() { - let newPath = window.location.pathname; - if (lastPath == newPath) - return; - lastPath = newPath; + try { + let newPath = window.location.pathname; + if (lastPath == newPath) + return; + lastPath = newPath; - let pathSpl = newPath.split("/"); - switch (pathSpl.length) { - case 1: - applyMainTheme(); //Root - break; + let pathSpl = newPath.split("/"); + switch (pathSpl.length) { + case 1: + applyMainTheme(); //Root + break; - case 2: - switch (pathSpl[1]) { - case "about": - case "announcements": - case "lists": - case "bookmarks": - applyMainTheme(); - break; + case 2: + switch (pathSpl[1]) { + case "about": + case "announcements": + case "lists": + case "bookmarks": + applyMainTheme(); + break; - default: - applyUserTheme(); - break; - } - break; + default: + applyUserTheme(); + break; + } + break; - case 3: - switch (pathSpl[1]) { - case "main": - applyMainTheme(); //Main timelines - break; + case 3: + switch (pathSpl[1]) { + case "main": + applyMainTheme(); //Main timelines + break; - case "users": - applyUserTheme(); - break; + case "users": + applyUserTheme(); + break; - case "notice": - //Continue playing - break; + case "notice": + //Continue playing + break; - default: - applyMainTheme(); - break; - } - break; + default: + applyMainTheme(); + break; + } + break; - default: - applyMainTheme(); - break; + default: + applyMainTheme(); + break; + } + } catch (e) { + console.error(e); } }