mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-02 21:19:12 +00:00
create a useismobilewidth method for standardized mobile view detection.
This commit is contained in:
@@ -5,7 +5,7 @@ import styles from "./agents.module.css";
|
|||||||
import Image from "next/image";
|
import Image from "next/image";
|
||||||
import useSWR from "swr";
|
import useSWR from "swr";
|
||||||
|
|
||||||
import { useEffect, useState } from "react";
|
import { useState } from "react";
|
||||||
|
|
||||||
import { useAuthenticatedData, UserProfile } from "../common/auth";
|
import { useAuthenticatedData, UserProfile } from "../common/auth";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
@@ -13,14 +13,7 @@ import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/comp
|
|||||||
|
|
||||||
import { PaperPlaneTilt, Lightning, Plus } from "@phosphor-icons/react";
|
import { PaperPlaneTilt, Lightning, Plus } from "@phosphor-icons/react";
|
||||||
|
|
||||||
import {
|
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
||||||
Card,
|
|
||||||
CardContent,
|
|
||||||
CardDescription,
|
|
||||||
CardFooter,
|
|
||||||
CardHeader,
|
|
||||||
CardTitle,
|
|
||||||
} from "@/components/ui/card";
|
|
||||||
import {
|
import {
|
||||||
Dialog,
|
Dialog,
|
||||||
DialogContent,
|
DialogContent,
|
||||||
@@ -41,10 +34,10 @@ import {
|
|||||||
import LoginPrompt from "../components/loginPrompt/loginPrompt";
|
import LoginPrompt from "../components/loginPrompt/loginPrompt";
|
||||||
import { InlineLoading } from "../components/loading/loading";
|
import { InlineLoading } from "../components/loading/loading";
|
||||||
import SidePanel from "../components/sidePanel/chatHistorySidePanel";
|
import SidePanel from "../components/sidePanel/chatHistorySidePanel";
|
||||||
import NavMenu from "../components/navMenu/navMenu";
|
|
||||||
import { getIconFromIconName } from "../common/iconUtils";
|
import { getIconFromIconName } from "../common/iconUtils";
|
||||||
import { convertColorToTextClass } from "../common/colorUtils";
|
import { convertColorToTextClass } from "../common/colorUtils";
|
||||||
import { Alert, AlertDescription } from "@/components/ui/alert";
|
import { Alert, AlertDescription } from "@/components/ui/alert";
|
||||||
|
import { useIsMobileWidth } from "../common/utils";
|
||||||
|
|
||||||
export interface AgentData {
|
export interface AgentData {
|
||||||
slug: string;
|
slug: string;
|
||||||
@@ -265,18 +258,8 @@ export default function Agents() {
|
|||||||
revalidateOnFocus: false,
|
revalidateOnFocus: false,
|
||||||
});
|
});
|
||||||
const authenticatedData = useAuthenticatedData();
|
const authenticatedData = useAuthenticatedData();
|
||||||
const [isMobileWidth, setIsMobileWidth] = useState(false);
|
|
||||||
const [showLoginPrompt, setShowLoginPrompt] = useState(false);
|
const [showLoginPrompt, setShowLoginPrompt] = useState(false);
|
||||||
|
const isMobileWidth = useIsMobileWidth();
|
||||||
useEffect(() => {
|
|
||||||
if (typeof window !== "undefined") {
|
|
||||||
setIsMobileWidth(window.innerWidth < 786);
|
|
||||||
}
|
|
||||||
|
|
||||||
window.addEventListener("resize", () => {
|
|
||||||
setIsMobileWidth(window.innerWidth < 786);
|
|
||||||
});
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ import { Input } from "@/components/ui/input";
|
|||||||
import { Dialog, DialogContent, DialogTrigger } from "@/components/ui/dialog";
|
import { Dialog, DialogContent, DialogTrigger } from "@/components/ui/dialog";
|
||||||
import { DialogTitle } from "@radix-ui/react-dialog";
|
import { DialogTitle } from "@radix-ui/react-dialog";
|
||||||
import { Textarea } from "@/components/ui/textarea";
|
import { Textarea } from "@/components/ui/textarea";
|
||||||
import { LocationData, useIPLocationData } from "../common/utils";
|
import { LocationData, useIPLocationData, useIsMobileWidth } from "../common/utils";
|
||||||
|
|
||||||
import styles from "./automations.module.css";
|
import styles from "./automations.module.css";
|
||||||
import ShareLink from "../components/shareLink/shareLink";
|
import ShareLink from "../components/shareLink/shareLink";
|
||||||
@@ -53,13 +53,10 @@ import {
|
|||||||
CalendarDots,
|
CalendarDots,
|
||||||
Clock,
|
Clock,
|
||||||
ClockAfternoon,
|
ClockAfternoon,
|
||||||
ClockCounterClockwise,
|
|
||||||
DotsThreeVertical,
|
DotsThreeVertical,
|
||||||
Envelope,
|
Envelope,
|
||||||
Info,
|
|
||||||
Lightning,
|
Lightning,
|
||||||
MapPinSimple,
|
MapPinSimple,
|
||||||
Pencil,
|
|
||||||
Play,
|
Play,
|
||||||
Plus,
|
Plus,
|
||||||
Trash,
|
Trash,
|
||||||
@@ -980,20 +977,10 @@ export default function Automations() {
|
|||||||
const [allNewAutomations, setAllNewAutomations] = useState<AutomationsData[]>([]);
|
const [allNewAutomations, setAllNewAutomations] = useState<AutomationsData[]>([]);
|
||||||
const [suggestedAutomations, setSuggestedAutomations] = useState<AutomationsData[]>([]);
|
const [suggestedAutomations, setSuggestedAutomations] = useState<AutomationsData[]>([]);
|
||||||
const [showLoginPrompt, setShowLoginPrompt] = useState(false);
|
const [showLoginPrompt, setShowLoginPrompt] = useState(false);
|
||||||
const [isMobileWidth, setIsMobileWidth] = useState(false);
|
const isMobileWidth = useIsMobileWidth();
|
||||||
|
|
||||||
const ipLocationData = useIPLocationData();
|
const ipLocationData = useIPLocationData();
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (window.innerWidth < 786) {
|
|
||||||
setIsMobileWidth(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
window.addEventListener("resize", () => {
|
|
||||||
setIsMobileWidth(window.innerWidth < 786);
|
|
||||||
});
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (newAutomationData) {
|
if (newAutomationData) {
|
||||||
setAllNewAutomations([...allNewAutomations, newAutomationData]);
|
setAllNewAutomations([...allNewAutomations, newAutomationData]);
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import { processMessageChunk } from "../common/chatFunctions";
|
|||||||
import "katex/dist/katex.min.css";
|
import "katex/dist/katex.min.css";
|
||||||
|
|
||||||
import { Context, OnlineContext, StreamMessage } from "../components/chatMessage/chatMessage";
|
import { Context, OnlineContext, StreamMessage } from "../components/chatMessage/chatMessage";
|
||||||
import { useIPLocationData, welcomeConsole } from "../common/utils";
|
import { useIPLocationData, useIsMobileWidth, welcomeConsole } from "../common/utils";
|
||||||
import ChatInputArea, { ChatOptions } from "../components/chatInputArea/chatInputArea";
|
import ChatInputArea, { ChatOptions } from "../components/chatInputArea/chatInputArea";
|
||||||
import { useAuthenticatedData } from "../common/auth";
|
import { useAuthenticatedData } from "../common/auth";
|
||||||
import { AgentData } from "../agents/page";
|
import { AgentData } from "../agents/page";
|
||||||
@@ -116,9 +116,9 @@ export default function Chat() {
|
|||||||
const [queryToProcess, setQueryToProcess] = useState<string>("");
|
const [queryToProcess, setQueryToProcess] = useState<string>("");
|
||||||
const [processQuerySignal, setProcessQuerySignal] = useState(false);
|
const [processQuerySignal, setProcessQuerySignal] = useState(false);
|
||||||
const [uploadedFiles, setUploadedFiles] = useState<string[]>([]);
|
const [uploadedFiles, setUploadedFiles] = useState<string[]>([]);
|
||||||
const [isMobileWidth, setIsMobileWidth] = useState(false);
|
|
||||||
const locationData = useIPLocationData();
|
const locationData = useIPLocationData();
|
||||||
const authenticatedData = useAuthenticatedData();
|
const authenticatedData = useAuthenticatedData();
|
||||||
|
const isMobileWidth = useIsMobileWidth();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetch("/api/chat/options")
|
fetch("/api/chat/options")
|
||||||
@@ -136,12 +136,6 @@ export default function Chat() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
welcomeConsole();
|
welcomeConsole();
|
||||||
|
|
||||||
setIsMobileWidth(window.innerWidth < 786);
|
|
||||||
|
|
||||||
window.addEventListener("resize", () => {
|
|
||||||
setIsMobileWidth(window.innerWidth < 786);
|
|
||||||
});
|
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { useEffect, useState } from "react";
|
||||||
import useSWR from "swr";
|
import useSWR from "swr";
|
||||||
|
|
||||||
export interface LocationData {
|
export interface LocationData {
|
||||||
@@ -54,3 +55,23 @@ export function useIPLocationData() {
|
|||||||
|
|
||||||
return locationData;
|
return locationData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function useIsMobileWidth() {
|
||||||
|
const [isMobileWidth, setIsMobileWidth] = useState(false);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const handleResize = () => {
|
||||||
|
if (window.innerWidth <= 768) {
|
||||||
|
setIsMobileWidth(true);
|
||||||
|
} else {
|
||||||
|
setIsMobileWidth(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
handleResize();
|
||||||
|
window.addEventListener("resize", handleResize);
|
||||||
|
return () => window.removeEventListener("resize", handleResize);
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return isMobileWidth;
|
||||||
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import ProfileCard from "../profileCard/profileCard";
|
|||||||
import { getIconFromIconName } from "@/app/common/iconUtils";
|
import { getIconFromIconName } from "@/app/common/iconUtils";
|
||||||
import { AgentData } from "@/app/agents/page";
|
import { AgentData } from "@/app/agents/page";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
import { useIsMobileWidth } from "@/app/common/utils";
|
||||||
|
|
||||||
interface ChatResponse {
|
interface ChatResponse {
|
||||||
status: string;
|
status: string;
|
||||||
@@ -75,15 +76,7 @@ export default function ChatHistory(props: ChatHistoryProps) {
|
|||||||
number | null
|
number | null
|
||||||
>(null);
|
>(null);
|
||||||
const [fetchingData, setFetchingData] = useState(false);
|
const [fetchingData, setFetchingData] = useState(false);
|
||||||
const [isMobileWidth, setIsMobileWidth] = useState(false);
|
const isMobileWidth = useIsMobileWidth();
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
window.addEventListener("resize", () => {
|
|
||||||
setIsMobileWidth(window.innerWidth < 786);
|
|
||||||
});
|
|
||||||
|
|
||||||
setIsMobileWidth(window.innerWidth < 786);
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// This function ensures that scrolling to bottom happens after the data (chat messages) has been updated and rendered the first time.
|
// This function ensures that scrolling to bottom happens after the data (chat messages) has been updated and rendered the first time.
|
||||||
|
|||||||
@@ -22,33 +22,17 @@ import {
|
|||||||
DropdownMenuSeparator,
|
DropdownMenuSeparator,
|
||||||
DropdownMenuTrigger,
|
DropdownMenuTrigger,
|
||||||
} from "@/components/ui/dropdown-menu";
|
} from "@/components/ui/dropdown-menu";
|
||||||
import {
|
import { Moon, Sun, UserCircle, Question, GearFine, ArrowRight } from "@phosphor-icons/react";
|
||||||
Moon,
|
|
||||||
Sun,
|
|
||||||
UserCircle,
|
|
||||||
User,
|
|
||||||
Robot,
|
|
||||||
MagnifyingGlass,
|
|
||||||
Question,
|
|
||||||
GearFine,
|
|
||||||
ArrowRight,
|
|
||||||
UsersFour,
|
|
||||||
} from "@phosphor-icons/react";
|
|
||||||
import { KhojAgentLogo, KhojAutomationLogo, KhojSearchLogo } from "../logo/khojLogo";
|
import { KhojAgentLogo, KhojAutomationLogo, KhojSearchLogo } from "../logo/khojLogo";
|
||||||
|
import { useIsMobileWidth } from "@/app/common/utils";
|
||||||
|
|
||||||
export default function NavMenu() {
|
export default function NavMenu() {
|
||||||
const userData = useAuthenticatedData();
|
const userData = useAuthenticatedData();
|
||||||
const [isMobileWidth, setIsMobileWidth] = useState(false);
|
|
||||||
const [darkMode, setDarkMode] = useState(false);
|
const [darkMode, setDarkMode] = useState(false);
|
||||||
const [initialLoadDone, setInitialLoadDone] = useState(false);
|
const [initialLoadDone, setInitialLoadDone] = useState(false);
|
||||||
|
const isMobileWidth = useIsMobileWidth();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setIsMobileWidth(window.innerWidth < 786);
|
|
||||||
|
|
||||||
window.addEventListener("resize", () => {
|
|
||||||
setIsMobileWidth(window.innerWidth < 786);
|
|
||||||
});
|
|
||||||
|
|
||||||
if (localStorage.getItem("theme") === "dark") {
|
if (localStorage.getItem("theme") === "dark") {
|
||||||
document.documentElement.classList.add("dark");
|
document.documentElement.classList.add("dark");
|
||||||
setDarkMode(true);
|
setDarkMode(true);
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ interface SuggestionCardProps {
|
|||||||
|
|
||||||
export default function SuggestionCard(data: SuggestionCardProps) {
|
export default function SuggestionCard(data: SuggestionCardProps) {
|
||||||
const bgColors = converColorToBgGradient(data.color);
|
const bgColors = converColorToBgGradient(data.color);
|
||||||
const cardClassName = `${styles.card} ${bgColors} md:w-full md:h-fit sm:w-full sm:h-fit lg:w-[200px] lg:h-[200px] cursor-pointer`;
|
const cardClassName = `${styles.card} ${bgColors} md:w-full md:h-fit sm:w-full h-fit md:w-[200px] md:h-[200px] cursor-pointer`;
|
||||||
const titleClassName = `${styles.title} pt-2 dark:text-white dark:font-bold`;
|
const titleClassName = `${styles.title} pt-2 dark:text-white dark:font-bold`;
|
||||||
const descriptionClassName = `${styles.text} dark:text-white`;
|
const descriptionClassName = `${styles.text} dark:text-white`;
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import { Button } from "@/components/ui/button";
|
|||||||
import { Card, CardContent, CardFooter, CardHeader, CardTitle } from "@/components/ui/card";
|
import { Card, CardContent, CardFooter, CardHeader, CardTitle } from "@/components/ui/card";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import SidePanel from "../components/sidePanel/chatHistorySidePanel";
|
import SidePanel from "../components/sidePanel/chatHistorySidePanel";
|
||||||
|
import { useIsMobileWidth } from "../common/utils";
|
||||||
|
|
||||||
const chatURL = "/api/chat";
|
const chatURL = "/api/chat";
|
||||||
const verificationPrecursor =
|
const verificationPrecursor =
|
||||||
@@ -136,7 +137,7 @@ function ReferenceVerification(props: ReferenceVerificationProps) {
|
|||||||
const [initialResponse, setInitialResponse] = useState("");
|
const [initialResponse, setInitialResponse] = useState("");
|
||||||
const [isLoading, setIsLoading] = useState(true);
|
const [isLoading, setIsLoading] = useState(true);
|
||||||
const verificationStatement = `${props.message}. Use this link for reference: ${props.additionalLink}`;
|
const verificationStatement = `${props.message}. Use this link for reference: ${props.additionalLink}`;
|
||||||
const [isMobileWidth, setIsMobileWidth] = useState(false);
|
const isMobileWidth = useIsMobileWidth();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (props.prefilledResponse) {
|
if (props.prefilledResponse) {
|
||||||
@@ -151,12 +152,6 @@ function ReferenceVerification(props: ReferenceVerificationProps) {
|
|||||||
() => {},
|
() => {},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
setIsMobileWidth(window.innerWidth < 786);
|
|
||||||
|
|
||||||
window.addEventListener("resize", () => {
|
|
||||||
setIsMobileWidth(window.innerWidth < 786);
|
|
||||||
});
|
|
||||||
}, [verificationStatement, props.conversationId, props.prefilledResponse]);
|
}, [verificationStatement, props.conversationId, props.prefilledResponse]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -260,7 +255,7 @@ export default function FactChecker() {
|
|||||||
const [initialReferences, setInitialReferences] = useState<ResponseWithReferences>();
|
const [initialReferences, setInitialReferences] = useState<ResponseWithReferences>();
|
||||||
const [childReferences, setChildReferences] = useState<SupplementReferences[]>();
|
const [childReferences, setChildReferences] = useState<SupplementReferences[]>();
|
||||||
const [modelUsed, setModelUsed] = useState<Model>();
|
const [modelUsed, setModelUsed] = useState<Model>();
|
||||||
const [isMobileWidth, setIsMobileWidth] = useState(false);
|
const isMobileWidth = useIsMobileWidth();
|
||||||
|
|
||||||
const [conversationID, setConversationID] = useState("");
|
const [conversationID, setConversationID] = useState("");
|
||||||
const [runId, setRunId] = useState("");
|
const [runId, setRunId] = useState("");
|
||||||
@@ -282,14 +277,6 @@ export default function FactChecker() {
|
|||||||
setChildReferences(newReferences);
|
setChildReferences(newReferences);
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
setIsMobileWidth(window.innerWidth < 786);
|
|
||||||
|
|
||||||
window.addEventListener("resize", () => {
|
|
||||||
setIsMobileWidth(window.innerWidth < 786);
|
|
||||||
});
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
let userData = useAuthenticatedData();
|
let userData = useAuthenticatedData();
|
||||||
|
|
||||||
function storeData() {
|
function storeData() {
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import { convertColorToBorderClass } from "@/app/common/colorUtils";
|
|||||||
import { getIconFromIconName } from "@/app/common/iconUtils";
|
import { getIconFromIconName } from "@/app/common/iconUtils";
|
||||||
import { AgentData } from "@/app/agents/page";
|
import { AgentData } from "@/app/agents/page";
|
||||||
import { createNewConversation } from "./common/chatFunctions";
|
import { createNewConversation } from "./common/chatFunctions";
|
||||||
|
import { useIsMobileWidth } from "./common/utils";
|
||||||
|
|
||||||
interface ChatBodyDataProps {
|
interface ChatBodyDataProps {
|
||||||
chatOptionsData: ChatOptions | null;
|
chatOptionsData: ChatOptions | null;
|
||||||
@@ -325,7 +326,7 @@ export default function Home() {
|
|||||||
const [isLoading, setLoading] = useState(true);
|
const [isLoading, setLoading] = useState(true);
|
||||||
const [conversationId, setConversationID] = useState<string | null>(null);
|
const [conversationId, setConversationID] = useState<string | null>(null);
|
||||||
const [uploadedFiles, setUploadedFiles] = useState<string[]>([]);
|
const [uploadedFiles, setUploadedFiles] = useState<string[]>([]);
|
||||||
const [isMobileWidth, setIsMobileWidth] = useState(false);
|
const isMobileWidth = useIsMobileWidth();
|
||||||
|
|
||||||
const { userConfig: initialUserConfig, isLoadingUserConfig } = useUserConfig(true);
|
const { userConfig: initialUserConfig, isLoadingUserConfig } = useUserConfig(true);
|
||||||
const [userConfig, setUserConfig] = useState<UserConfig | null>(null);
|
const [userConfig, setUserConfig] = useState<UserConfig | null>(null);
|
||||||
@@ -353,12 +354,6 @@ export default function Home() {
|
|||||||
console.error(err);
|
console.error(err);
|
||||||
return;
|
return;
|
||||||
});
|
});
|
||||||
|
|
||||||
setIsMobileWidth(window.innerWidth < 786);
|
|
||||||
|
|
||||||
window.addEventListener("resize", () => {
|
|
||||||
setIsMobileWidth(window.innerWidth < 786);
|
|
||||||
});
|
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
if (isLoading) {
|
if (isLoading) {
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ import {
|
|||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { getIconFromFilename } from "../common/iconUtils";
|
import { getIconFromFilename } from "../common/iconUtils";
|
||||||
|
import { useIsMobileWidth } from "../common/utils";
|
||||||
|
|
||||||
interface AdditionalData {
|
interface AdditionalData {
|
||||||
file: string;
|
file: string;
|
||||||
@@ -165,23 +166,16 @@ function focusNote(note: SearchResult) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default function Search() {
|
export default function Search() {
|
||||||
const authenticatedData = useAuthenticatedData();
|
|
||||||
const [searchQuery, setSearchQuery] = useState("");
|
const [searchQuery, setSearchQuery] = useState("");
|
||||||
const [isMobileWidth, setIsMobileWidth] = useState(false);
|
|
||||||
const [title, setTitle] = useState("Search");
|
|
||||||
const [searchResults, setSearchResults] = useState<SearchResult[] | null>(null);
|
const [searchResults, setSearchResults] = useState<SearchResult[] | null>(null);
|
||||||
const [searchResultsLoading, setSearchResultsLoading] = useState(false);
|
const [searchResultsLoading, setSearchResultsLoading] = useState(false);
|
||||||
const [focusSearchResult, setFocusSearchResult] = useState<SearchResult | null>(null);
|
const [focusSearchResult, setFocusSearchResult] = useState<SearchResult | null>(null);
|
||||||
const [exampleQuery, setExampleQuery] = useState("");
|
const [exampleQuery, setExampleQuery] = useState("");
|
||||||
const searchTimeoutRef = useRef<NodeJS.Timeout | null>(null);
|
const searchTimeoutRef = useRef<NodeJS.Timeout | null>(null);
|
||||||
|
|
||||||
|
const isMobileWidth = useIsMobileWidth();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setIsMobileWidth(window.innerWidth < 786);
|
|
||||||
|
|
||||||
window.addEventListener("resize", () => {
|
|
||||||
setIsMobileWidth(window.innerWidth < 786);
|
|
||||||
});
|
|
||||||
|
|
||||||
setExampleQuery(
|
setExampleQuery(
|
||||||
naturalLanguageSearchQueryExamples[
|
naturalLanguageSearchQueryExamples[
|
||||||
Math.floor(Math.random() * naturalLanguageSearchQueryExamples.length)
|
Math.floor(Math.random() * naturalLanguageSearchQueryExamples.length)
|
||||||
@@ -189,10 +183,6 @@ export default function Search() {
|
|||||||
);
|
);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
setTitle(isMobileWidth ? "" : "Search");
|
|
||||||
}, [isMobileWidth]);
|
|
||||||
|
|
||||||
function search() {
|
function search() {
|
||||||
if (searchResultsLoading || !searchQuery.trim()) return;
|
if (searchResultsLoading || !searchQuery.trim()) return;
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import { Suspense, useEffect, useRef, useState } from "react";
|
|||||||
import { useToast } from "@/components/ui/use-toast";
|
import { useToast } from "@/components/ui/use-toast";
|
||||||
|
|
||||||
import { useUserConfig, ModelOptions, UserConfig } from "../common/auth";
|
import { useUserConfig, ModelOptions, UserConfig } from "../common/auth";
|
||||||
import { toTitleCase } from "../common/utils";
|
import { toTitleCase, useIsMobileWidth } from "../common/utils";
|
||||||
|
|
||||||
import { isValidPhoneNumber } from "libphonenumber-js";
|
import { isValidPhoneNumber } from "libphonenumber-js";
|
||||||
|
|
||||||
@@ -37,7 +37,6 @@ import {
|
|||||||
ChatCircleText,
|
ChatCircleText,
|
||||||
Key,
|
Key,
|
||||||
Palette,
|
Palette,
|
||||||
SpeakerHigh,
|
|
||||||
UserCircle,
|
UserCircle,
|
||||||
FileMagnifyingGlass,
|
FileMagnifyingGlass,
|
||||||
Trash,
|
Trash,
|
||||||
@@ -500,7 +499,6 @@ enum PhoneNumberValidationState {
|
|||||||
|
|
||||||
export default function SettingsView() {
|
export default function SettingsView() {
|
||||||
const [title, setTitle] = useState("Settings");
|
const [title, setTitle] = useState("Settings");
|
||||||
const [isMobileWidth, setIsMobileWidth] = useState(false);
|
|
||||||
const { apiKeys, generateAPIKey, copyAPIKey, deleteAPIKey } = useApiKeys();
|
const { apiKeys, generateAPIKey, copyAPIKey, deleteAPIKey } = useApiKeys();
|
||||||
const { userConfig: initialUserConfig } = useUserConfig(true);
|
const { userConfig: initialUserConfig } = useUserConfig(true);
|
||||||
const [userConfig, setUserConfig] = useState<UserConfig | null>(null);
|
const [userConfig, setUserConfig] = useState<UserConfig | null>(null);
|
||||||
@@ -513,6 +511,8 @@ export default function SettingsView() {
|
|||||||
);
|
);
|
||||||
const [isManageFilesModalOpen, setIsManageFilesModalOpen] = useState(false);
|
const [isManageFilesModalOpen, setIsManageFilesModalOpen] = useState(false);
|
||||||
const { toast } = useToast();
|
const { toast } = useToast();
|
||||||
|
const isMobileWidth = useIsMobileWidth();
|
||||||
|
|
||||||
const cardClassName =
|
const cardClassName =
|
||||||
"w-full lg:w-1/3 grid grid-flow-column border border-gray-300 shadow-md rounded-lg bg-gradient-to-b from-background to-gray-50 dark:to-gray-950";
|
"w-full lg:w-1/3 grid grid-flow-column border border-gray-300 shadow-md rounded-lg bg-gradient-to-b from-background to-gray-50 dark:to-gray-950";
|
||||||
|
|
||||||
@@ -530,13 +530,6 @@ export default function SettingsView() {
|
|||||||
setNotionToken(initialUserConfig?.notion_token ?? null);
|
setNotionToken(initialUserConfig?.notion_token ?? null);
|
||||||
}, [initialUserConfig]);
|
}, [initialUserConfig]);
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
setIsMobileWidth(window.innerWidth < 786);
|
|
||||||
const handleResize = () => setIsMobileWidth(window.innerWidth < 786);
|
|
||||||
window.addEventListener("resize", handleResize);
|
|
||||||
return () => window.removeEventListener("resize", handleResize);
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const sendOTP = async () => {
|
const sendOTP = async () => {
|
||||||
try {
|
try {
|
||||||
const response = await fetch(`/api/phone?phone_number=${phoneNumber}`, {
|
const response = await fetch(`/api/phone?phone_number=${phoneNumber}`, {
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import Loading from "../../components/loading/loading";
|
|||||||
|
|
||||||
import "katex/dist/katex.min.css";
|
import "katex/dist/katex.min.css";
|
||||||
|
|
||||||
import { useIPLocationData, welcomeConsole } from "../../common/utils";
|
import { useIPLocationData, useIsMobileWidth, welcomeConsole } from "../../common/utils";
|
||||||
import { useAuthenticatedData } from "@/app/common/auth";
|
import { useAuthenticatedData } from "@/app/common/auth";
|
||||||
|
|
||||||
import ChatInputArea, { ChatOptions } from "@/app/components/chatInputArea/chatInputArea";
|
import ChatInputArea, { ChatOptions } from "@/app/components/chatInputArea/chatInputArea";
|
||||||
@@ -100,11 +100,11 @@ export default function SharedChat() {
|
|||||||
const [queryToProcess, setQueryToProcess] = useState<string>("");
|
const [queryToProcess, setQueryToProcess] = useState<string>("");
|
||||||
const [processQuerySignal, setProcessQuerySignal] = useState(false);
|
const [processQuerySignal, setProcessQuerySignal] = useState(false);
|
||||||
const [uploadedFiles, setUploadedFiles] = useState<string[]>([]);
|
const [uploadedFiles, setUploadedFiles] = useState<string[]>([]);
|
||||||
const [isMobileWidth, setIsMobileWidth] = useState(false);
|
|
||||||
const [paramSlug, setParamSlug] = useState<string | undefined>(undefined);
|
const [paramSlug, setParamSlug] = useState<string | undefined>(undefined);
|
||||||
|
|
||||||
const locationData = useIPLocationData();
|
const locationData = useIPLocationData();
|
||||||
const authenticatedData = useAuthenticatedData();
|
const authenticatedData = useAuthenticatedData();
|
||||||
|
const isMobileWidth = useIsMobileWidth();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetch("/api/chat/options")
|
fetch("/api/chat/options")
|
||||||
@@ -123,12 +123,6 @@ export default function SharedChat() {
|
|||||||
|
|
||||||
welcomeConsole();
|
welcomeConsole();
|
||||||
|
|
||||||
setIsMobileWidth(window.innerWidth < 786);
|
|
||||||
|
|
||||||
window.addEventListener("resize", () => {
|
|
||||||
setIsMobileWidth(window.innerWidth < 786);
|
|
||||||
});
|
|
||||||
|
|
||||||
setParamSlug(window.location.pathname.split("/").pop() || "");
|
setParamSlug(window.location.pathname.split("/").pop() || "");
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user