mirror of
https://github.com/sqlchat/sqlchat.git
synced 2025-07-28 17:53:21 +08:00
chore: dynamic import query drawer
This commit is contained in:
@ -12,9 +12,9 @@ type RawQueryResult = {
|
||||
|
||||
const QueryDrawer = () => {
|
||||
const queryStore = useQueryStore();
|
||||
const context = queryStore.context;
|
||||
const [rawResults, setRawResults] = useState<RawQueryResult[]>([]);
|
||||
const [isLoading, setIsLoading] = useState(true);
|
||||
const context = queryStore.context;
|
||||
const columns = Object.keys(head(rawResults) || {}).map((key) => {
|
||||
return {
|
||||
name: key,
|
||||
@ -23,6 +23,10 @@ const QueryDrawer = () => {
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (!queryStore.showDrawer) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!context) {
|
||||
toast.error("No execution context found.");
|
||||
setIsLoading(false);
|
||||
@ -56,7 +60,7 @@ const QueryDrawer = () => {
|
||||
};
|
||||
|
||||
executeStatement();
|
||||
}, [context]);
|
||||
}, [context, queryStore.showDrawer]);
|
||||
|
||||
const close = () => queryStore.toggleDrawer(false);
|
||||
|
||||
|
@ -3,7 +3,6 @@ import Head from "next/head";
|
||||
import dynamic from "next/dynamic";
|
||||
import React, { useEffect } from "react";
|
||||
import { ResponsiveWidth, useLayoutStore } from "@/store";
|
||||
import QueryDrawer from "@/components/QueryDrawer";
|
||||
|
||||
// Use dynamic import to avoid page hydrated.
|
||||
// reference: https://github.com/pmndrs/zustand/issues/1145#issuecomment-1316431268
|
||||
@ -13,6 +12,9 @@ const ConnectionSidebar = dynamic(() => import("@/components/ConnectionSidebar")
|
||||
const ChatView = dynamic(() => import("@/components/ChatView"), {
|
||||
ssr: false,
|
||||
});
|
||||
const QueryDrawer = dynamic(() => import("@/components/QueryDrawer"), {
|
||||
ssr: false,
|
||||
});
|
||||
|
||||
const ChatPage: NextPage = () => {
|
||||
const layoutStore = useLayoutStore();
|
||||
|
Reference in New Issue
Block a user