Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit35b0614

Browse files
iamfaranraheeliftikhar5
authored andcommitted
fix no threads infinite re render
1 parentb2dcf3f commit35b0614

File tree

1 file changed

+10
-0
lines changed
  • client/packages/lowcoder/src/comps/comps/chatComp/components/context

1 file changed

+10
-0
lines changed

‎client/packages/lowcoder/src/comps/comps/chatComp/components/context/ChatContext.tsx‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,13 +303,23 @@ export function ChatProvider({ children, storage }: {
303303
};
304304

305305
constdeleteThread=async(threadId:string)=>{
306+
// Determine if this is the last remaining thread BEFORE we delete it
307+
constisLastThread=state.threadList.length===1;
308+
306309
// Update local state first
307310
dispatch({type:"DELETE_THREAD", threadId});
308311

309312
// Delete from storage
310313
try{
311314
awaitstorage.deleteThread(threadId);
312315
dispatch({type:"MARK_SAVED"});
316+
// avoid deleting the last thread
317+
// if there are no threads left, create a new one
318+
// avoid infinite re-renders
319+
if(isLastThread){
320+
constnewThreadId=awaitcreateThread("New Chat");
321+
setCurrentThread(newThreadId);
322+
}
313323
}catch(error){
314324
console.error("Failed to delete thread:",error);
315325
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp