From cfdbd93695d4fdafcf0d274e63a3284cea4798a2 Mon Sep 17 00:00:00 2001 From: Mononaut Date: Wed, 18 Oct 2023 21:13:35 +0000 Subject: [PATCH] Fix SSR matchMedia shim --- frontend/server.ts | 5 +++-- frontend/src/app/shared/pipes/bytes-pipe/utils.ts | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/frontend/server.ts b/frontend/server.ts index 29677959d..ffce336f5 100644 --- a/frontend/server.ts +++ b/frontend/server.ts @@ -22,9 +22,10 @@ const win = domino.createWindow(template); win.__env = global.__env; // @ts-ignore -win.matchMedia = () => { +win.matchMedia = (media) => { return { - matches: true + media, + matches: true, }; }; diff --git a/frontend/src/app/shared/pipes/bytes-pipe/utils.ts b/frontend/src/app/shared/pipes/bytes-pipe/utils.ts index 7c88c83bc..138218a43 100644 --- a/frontend/src/app/shared/pipes/bytes-pipe/utils.ts +++ b/frontend/src/app/shared/pipes/bytes-pipe/utils.ts @@ -323,7 +323,7 @@ export function hasTouchScreen(): boolean { // @ts-ignore hasTouchScreen = navigator.msMaxTouchPoints > 0; } else { - const mQ = matchMedia?.('(pointer:coarse)'); + const mQ = window.matchMedia?.('(pointer:coarse)'); if (mQ?.media === '(pointer:coarse)') { hasTouchScreen = !!mQ.matches; } else if ('orientation' in window) {