refactor(server/utils): isElectron - replace fn with boolean

this values cannot change during runtime,
=> there is no need to have these checks
as dynamic function, instead just
export the boolean value directly
This commit is contained in:
Panagiotis Papadopoulos
2025-01-22 18:57:06 +01:00
parent 94411cf418
commit ca2bb94200
16 changed files with 33 additions and 40 deletions

View File

@@ -18,7 +18,7 @@ if (env.isDev()) {
const debounce = (await import("debounce")).default;
const debouncedReloadFrontend = debounce(() => reloadFrontend("source code change"), 200);
chokidar
.watch(isElectron() ? "dist/src/public" : "src/public")
.watch(isElectron ? "dist/src/public" : "src/public")
.on("add", debouncedReloadFrontend)
.on("change", debouncedReloadFrontend)
.on("unlink", debouncedReloadFrontend);
@@ -62,7 +62,7 @@ function init(httpServer: HttpServer, sessionParser: SessionParser) {
webSocketServer = new WebSocketServer({
verifyClient: (info, done) => {
sessionParser(info.req, {}, () => {
const allowed = isElectron() || (info.req as any).session.loggedIn || (config.General && config.General.noAuthentication);
const allowed = isElectron || (info.req as any).session.loggedIn || (config.General && config.General.noAuthentication);
if (!allowed) {
log.error("WebSocket connection not allowed because session is neither electron nor logged in.");