mirror of
https://github.com/QuivrHQ/quivr.git
synced 2024-12-21 05:11:35 +03:00
dc64470d5d
* feat: make chat list hidden on mobile by default * feat: autoclose chat list on click * feat: move footer to chat lists bottom when user is logged in * feat: fix header when user is logged in * chore: refacto ChatMessages * feat: reverse chat list display on fetch * feat: fix new chat button
26 lines
607 B
TypeScript
26 lines
607 B
TypeScript
import { useEffect, useState } from "react";
|
|
|
|
export const useDevice = (): { isMobile: boolean } => {
|
|
const [isMobile, setIsMobile] = useState(false);
|
|
|
|
useEffect(() => {
|
|
const handleResize = () => {
|
|
const screenWidth = window.innerWidth;
|
|
setIsMobile(screenWidth < 576);
|
|
};
|
|
|
|
// Initial check
|
|
handleResize();
|
|
|
|
// Event listener for screen resize
|
|
window.addEventListener("resize", handleResize);
|
|
|
|
// Clean up event listener on component unmount
|
|
return () => {
|
|
window.removeEventListener("resize", handleResize);
|
|
};
|
|
}, []);
|
|
|
|
return { isMobile };
|
|
};
|