mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-10-23 00:53:38 +02:00
Prevent workspace diff sidebar layout flash
This commit is contained in:
1 parent
3d13029336
commit
0b9539fbbf
1 file changed
+4
-2
@@ -129,14 +129,16 @@ function writeStoredFileSidebarWidth(width: number) {
|
||||
}
|
||||
|
||||
function useIsDesktopDiffLayout() {
|
||||
const [isDesktop, setIsDesktop] = useState(false);
|
||||
const [isDesktop, setIsDesktop] = useState(() => {
|
||||
if (typeof window === "undefined" || typeof window.matchMedia !== "function") return false;
|
||||
return window.matchMedia("(min-width: 1024px)").matches;
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (typeof window === "undefined" || typeof window.matchMedia !== "function") return;
|
||||
|
||||
const query = window.matchMedia("(min-width: 1024px)");
|
||||
const update = () => setIsDesktop(query.matches);
|
||||
update();
|
||||
query.addEventListener("change", update);
|
||||
return () => query.removeEventListener("change", update);
|
||||
}, []);
|
||||
|
||||
Reference in new issue
Block a user