MCPcopy Create free account
hub / github.com/FlowiseAI/Flowise / clearChat

Function clearChat

packages/ui/src/views/chatmessage/ChatPopUp.jsx:87–131  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

85 }
86
87 const clearChat = async () => {
88 const confirmPayload = {
89 title: `Clear Chat History`,
90 description: `Are you sure you want to clear all chat history?`,
91 confirmButtonName: 'Clear',
92 cancelButtonName: 'Cancel'
93 }
94 const isConfirmed = await confirm(confirmPayload)
95
96 if (isConfirmed) {
97 try {
98 const objChatDetails = getLocalStorageChatflow(chatflowid)
99 if (!objChatDetails.chatId) return
100 await chatmessageApi.deleteChatmessage(chatflowid, { chatId: objChatDetails.chatId, chatType: 'INTERNAL' })
101 removeLocalStorageChatHistory(chatflowid)
102 resetChatDialog()
103 enqueueSnackbar({
104 message: 'Successfully cleared all chat history',
105 options: {
106 key: new Date().getTime() + Math.random(),
107 variant: 'success',
108 action: (key) => (
109 <Button style={{ color: 'white' }} onClick={() => closeSnackbar(key)}>
110 <IconX />
111 </Button>
112 )
113 }
114 })
115 } catch (error) {
116 enqueueSnackbar({
117 message: typeof error.response.data === 'object' ? error.response.data.message : error.response.data,
118 options: {
119 key: new Date().getTime() + Math.random(),
120 variant: 'error',
121 persist: true,
122 action: (key) => (
123 <Button style={{ color: 'white' }} onClick={() => closeSnackbar(key)}>
124 <IconX />
125 </Button>
126 )
127 }
128 })
129 }
130 }
131 }
132
133 useEffect(() => {
134 if (prevOpen.current === true && open === false) {

Callers

nothing calls this directly

Calls 7

getLocalStorageChatflowFunction · 0.90
enqueueSnackbarFunction · 0.90
closeSnackbarFunction · 0.90
confirmFunction · 0.85
resetChatDialogFunction · 0.85
getTimeMethod · 0.45

Tested by

no test coverage detected