mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-27 18:57:04 +02:00
refactor(idlewatcher): simplify loading.js console line handling and message fallback
Replace chained level checks with a validLevels list and includes(). Coalesce addConsoleLine call sites. Default missing payload.message to an empty string so the console does not show undefined.
This commit is contained in:
@@ -51,15 +51,12 @@ window.onload = async () => {
|
||||
* @param {EventLevel} [level]
|
||||
*/
|
||||
function addConsoleLine(type, message, timestamp, level) {
|
||||
const lvl =
|
||||
level === "debug" ||
|
||||
level === "info" ||
|
||||
level === "warn" ||
|
||||
level === "error"
|
||||
? level
|
||||
: type === "error"
|
||||
? "error"
|
||||
: "info";
|
||||
const validLevels = ["debug", "info", "warn", "error"];
|
||||
const lvl = validLevels.includes(level)
|
||||
? level
|
||||
: type === "error"
|
||||
? "error"
|
||||
: "info";
|
||||
const line = document.createElement("div");
|
||||
line.className = `console-line ${type} level-${lvl}`;
|
||||
|
||||
@@ -140,7 +137,7 @@ window.onload = async () => {
|
||||
eventSource.close();
|
||||
} else {
|
||||
// Show other message types
|
||||
const message = payload.message;
|
||||
const message = payload.message || "";
|
||||
addConsoleLine(type, message, timestamp, evt.level);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user