create a useismobilewidth method for standardized mobile view detection.

This commit is contained in:
sabaimran
2024-08-07 21:04:44 +05:30
parent 2943bed5d4
commit f28693c8c7
12 changed files with 48 additions and 127 deletions

View File

@@ -19,6 +19,7 @@ import ProfileCard from "../profileCard/profileCard";
import { getIconFromIconName } from "@/app/common/iconUtils";
import { AgentData } from "@/app/agents/page";
import React from "react";
import { useIsMobileWidth } from "@/app/common/utils";
interface ChatResponse {
status: string;
@@ -75,15 +76,7 @@ export default function ChatHistory(props: ChatHistoryProps) {
number | null
>(null);
const [fetchingData, setFetchingData] = useState(false);
const [isMobileWidth, setIsMobileWidth] = useState(false);
useEffect(() => {
window.addEventListener("resize", () => {
setIsMobileWidth(window.innerWidth < 786);
});
setIsMobileWidth(window.innerWidth < 786);
}, []);
const isMobileWidth = useIsMobileWidth();
useEffect(() => {
// This function ensures that scrolling to bottom happens after the data (chat messages) has been updated and rendered the first time.