diff --git a/apps/client/src/index.ts b/apps/client/src/index.ts index 795adc8cf..0d0ebd9e0 100644 --- a/apps/client/src/index.ts +++ b/apps/client/src/index.ts @@ -25,10 +25,24 @@ async function setupGlob() { window.global = globalThis; /* fixes https://github.com/webpack/webpack/issues/10035 */ window.glob = { ...json, - activeDialog: null + activeDialog: null, + device: getDevice() }; } +function getDevice() { + // Respect user's manual override via URL. + const urlParams = new URLSearchParams(window.location.search); + if (urlParams.has("desktop")) { + return "desktop"; + } else if (urlParams.has("mobile")) { + return "mobile"; + } + + const deviceCookie = document.cookie.split("; ").find(row => row.startsWith("trilium-device="))?.split("=")[1]; + return deviceCookie ?? "desktop"; +} + async function loadBootstrapCss() { // We have to selectively import Bootstrap CSS based on text direction. if (glob.isRtl) {