Commit 2c016606 authored by Joel's avatar Joel

fix: missing vars bind

parent 3df562d0
...@@ -65,6 +65,7 @@ const Main: FC<IMainProps> = ({ ...@@ -65,6 +65,7 @@ const Main: FC<IMainProps> = ({
/* /*
* conversation info * conversation info
*/ */
const [allConversationList, setAllConversationList] = useState<ConversationItem[]>([])
const { const {
conversationList, conversationList,
setConversationList, setConversationList,
...@@ -148,7 +149,7 @@ const Main: FC<IMainProps> = ({ ...@@ -148,7 +149,7 @@ const Main: FC<IMainProps> = ({
let notSyncToStateIntroduction = '' let notSyncToStateIntroduction = ''
let notSyncToStateInputs: Record<string, any> | undefined | null = {} let notSyncToStateInputs: Record<string, any> | undefined | null = {}
if (!isNewConversation) { if (!isNewConversation) {
const item = conversationList.find(item => item.id === currConversationId) const item = allConversationList.find(item => item.id === currConversationId)
notSyncToStateInputs = item?.inputs || {} notSyncToStateInputs = item?.inputs || {}
setCurrInputs(notSyncToStateInputs) setCurrInputs(notSyncToStateInputs)
notSyncToStateIntroduction = item?.introduction || '' notSyncToStateIntroduction = item?.introduction || ''
...@@ -256,6 +257,10 @@ const Main: FC<IMainProps> = ({ ...@@ -256,6 +257,10 @@ const Main: FC<IMainProps> = ({
return [] return []
} }
const fetchAllConversations = () => {
return fetchConversations(isInstalledApp, installedAppInfo?.id, undefined, undefined, 100)
}
const fetchInitData = () => { const fetchInitData = () => {
return Promise.all([isInstalledApp return Promise.all([isInstalledApp
? { ? {
...@@ -267,7 +272,7 @@ const Main: FC<IMainProps> = ({ ...@@ -267,7 +272,7 @@ const Main: FC<IMainProps> = ({
}, },
plan: 'basic', plan: 'basic',
} }
: fetchAppInfo(), fetchConversations(isInstalledApp, installedAppInfo?.id), fetchAppParams(isInstalledApp, installedAppInfo?.id)]) : fetchAppInfo(), fetchAllConversations(), fetchAppParams(isInstalledApp, installedAppInfo?.id)])
} }
// init // init
...@@ -282,10 +287,10 @@ const Main: FC<IMainProps> = ({ ...@@ -282,10 +287,10 @@ const Main: FC<IMainProps> = ({
setIsPublicVersion(tempIsPublicVersion) setIsPublicVersion(tempIsPublicVersion)
const prompt_template = '' const prompt_template = ''
// handle current conversation id // handle current conversation id
const { data: conversations, has_more } = conversationData as { data: ConversationItem[]; has_more: boolean } const { data: allConversations } = conversationData as { data: ConversationItem[]; has_more: boolean }
const _conversationId = getConversationIdFromStorage(appId) const _conversationId = getConversationIdFromStorage(appId)
const isNotNewConversation = conversations.some(item => item.id === _conversationId) const isNotNewConversation = allConversations.some(item => item.id === _conversationId)
// setHasMore(has_more) setAllConversationList(allConversations)
// fetch new conversation info // fetch new conversation info
const { user_input_form, opening_statement: introduction, suggested_questions_after_answer }: any = appParams const { user_input_form, opening_statement: introduction, suggested_questions_after_answer }: any = appParams
const prompt_variables = userInputsFormToPromptVariables(user_input_form) const prompt_variables = userInputsFormToPromptVariables(user_input_form)
...@@ -431,9 +436,8 @@ const Main: FC<IMainProps> = ({ ...@@ -431,9 +436,8 @@ const Main: FC<IMainProps> = ({
return return
if (getConversationIdChangeBecauseOfNew()) { if (getConversationIdChangeBecauseOfNew()) {
const { data: conversations, has_more }: any = await fetchConversations(isInstalledApp, installedAppInfo?.id) const { data: allConversations }: any = await fetchAllConversations()
// setHasMore(has_more) setAllConversationList(allConversations)
// setConversationList(conversations as ConversationItem[])
setControlUpdateConversationList(Date.now()) setControlUpdateConversationList(Date.now())
} }
setConversationIdChangeBecauseOfNew(false) setConversationIdChangeBecauseOfNew(false)
......
...@@ -57,9 +57,8 @@ export const fetchAppInfo = async () => { ...@@ -57,9 +57,8 @@ export const fetchAppInfo = async () => {
return get('/site') return get('/site')
} }
export const fetchConversations = async (isInstalledApp: boolean, installedAppId = '', last_id?: string, pinned?: boolean) => { export const fetchConversations = async (isInstalledApp: boolean, installedAppId = '', last_id?: string, pinned?: boolean, limit?: number) => {
console.log(pinned) return getAction('get', isInstalledApp)(getUrl('conversations', isInstalledApp, installedAppId), { params: { ...{ limit: limit || 20 }, ...(last_id ? { last_id } : {}), ...(pinned !== undefined ? { pinned } : {}) } })
return getAction('get', isInstalledApp)(getUrl('conversations', isInstalledApp, installedAppId), { params: { ...{ limit: 20 }, ...(last_id ? { last_id } : {}), ...(pinned !== undefined ? { pinned } : {}) } })
} }
export const pinConversation = async (isInstalledApp: boolean, installedAppId = '', id: string) => { export const pinConversation = async (isInstalledApp: boolean, installedAppId = '', id: string) => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment