select chat index after fetch

This commit is contained in:
2023-03-29 15:37:36 +08:00
parent c31c6cd84a
commit 5fc2c62b4f
2 changed files with 11 additions and 3 deletions

View File

@@ -205,7 +205,12 @@ export function App() {
DEL
</button>
</div>
<ChatBOX chatStore={chatStore} setChatStore={setChatStore} />
<ChatBOX
chatStore={chatStore}
setChatStore={setChatStore}
selectedChatIndex={selectedChatIndex}
setSelectedChatIndex={setSelectedChatIndex}
/>
</div>
);
}

View File

@@ -1,5 +1,5 @@
import { createRef } from "preact";
import { useEffect, useState } from "preact/hooks";
import { StateUpdater, useEffect, useState } from "preact/hooks";
import type { ChatStore } from "./app";
import ChatGPT, { ChunkMessage, FetchResponse } from "./chatgpt";
import Message from "./message";
@@ -8,6 +8,8 @@ import Settings from "./settings";
export default function ChatBOX(props: {
chatStore: ChatStore;
setChatStore: (cs: ChatStore) => void;
selectedChatIndex: number;
setSelectedChatIndex: StateUpdater<number>;
}) {
const { chatStore, setChatStore } = props;
// prevent error
@@ -134,6 +136,7 @@ export default function ChatBOX(props: {
alert(error);
} finally {
setShowGenerating(false);
props.setSelectedChatIndex(props.selectedChatIndex);
}
};
@@ -205,7 +208,7 @@ export default function ChatBOX(props: {
<br />
Endpoint: {chatStore.apiEndpoint}
<br />
<br />
NEW
<br />