Skip to content

Commit

Permalink
Merge pull request ChatGPTNextWeb#66 from iFwu/main
Browse files Browse the repository at this point in the history
fix: resolve hydration error
  • Loading branch information
Yidadaa authored Mar 27, 2023
2 parents f188841 + 9570691 commit d177066
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
1 change: 0 additions & 1 deletion app/api/chat-stream/route.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import type { ChatRequest } from "../chat/typing";
import { createParser } from "eventsource-parser";
import { NextRequest } from "next/server";

Expand Down
12 changes: 11 additions & 1 deletion app/components/home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,16 @@ function showMemoryPrompt(session: ChatSession) {
});
}

const useHasHydrated = () => {
const [hasHydrated, setHasHydrated] = useState<boolean>(false);

useEffect(() => {
setHasHydrated(true);
}, []);

return hasHydrated;
};

export function Home() {
const [createNewSession, currentIndex, removeSession] = useChatStore(
(state) => [
Expand All @@ -478,7 +488,7 @@ export function Home() {
state.removeSession,
]
);
const loading = !useChatStore?.persist?.hasHydrated();
const loading = !useHasHydrated();
const [showSideBar, setShowSideBar] = useState(true);

// setting
Expand Down
2 changes: 1 addition & 1 deletion app/components/settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ export function Settings(props: { closeSettings: () => void }) {
<input
type="number"
min={100}
max={4000}
max={4096}
value={config.modelConfig.max_tokens}
onChange={(e) =>
updateConfig(
Expand Down

0 comments on commit d177066

Please sign in to comment.