Switch to qrcode-generator library
This commit is contained in:
parent
17bee00821
commit
c8d32f0327
14 changed files with 155 additions and 696 deletions
27
ts/hooks/useDevicePixelRatio.ts
Normal file
27
ts/hooks/useDevicePixelRatio.ts
Normal file
|
@ -0,0 +1,27 @@
|
|||
// Copyright 2022 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import { useEffect, useState } from 'react';
|
||||
|
||||
export function useDevicePixelRatio(): number {
|
||||
const [result, setResult] = useState(window.devicePixelRatio);
|
||||
|
||||
useEffect(() => {
|
||||
const update = () => {
|
||||
setResult(window.devicePixelRatio);
|
||||
};
|
||||
|
||||
update();
|
||||
|
||||
const mediaQuery = window.matchMedia(
|
||||
`screen and (resolution: ${result}dppx)`
|
||||
);
|
||||
mediaQuery.addEventListener('change', update);
|
||||
|
||||
return () => {
|
||||
mediaQuery.removeEventListener('change', update);
|
||||
};
|
||||
}, [result]);
|
||||
|
||||
return result;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue