mirror of
https://github.com/abhinavxd/libredesk.git
synced 2026-09-22 18:43:33 +00:00
Fix widget: re-fetch convos on JWT set, prevent double conversation creation
This commit is contained in:
@@ -72,6 +72,13 @@ const setupParentMessageListeners = () => {
|
||||
} else if (event.data.type === 'SET_JWT_TOKEN') {
|
||||
if (event.data.jwt) {
|
||||
userStore.setSessionToken(event.data.jwt)
|
||||
// Re-fetch conversations with the new auth token.
|
||||
chatStore.conversations = null
|
||||
chatStore.fetchConversations().then(() => {
|
||||
if (widgetStore.config?.direct_to_conversation && chatStore.hasConversations) {
|
||||
chatStore.loadConversation(chatStore.getConversations[0].uuid)
|
||||
}
|
||||
})
|
||||
}
|
||||
} else if (event.data.type === 'CLEAR_SESSION') {
|
||||
userStore.clearSessionToken()
|
||||
|
||||
@@ -133,8 +133,8 @@ const sendMessageToConversation = async (messageText) => {
|
||||
}
|
||||
|
||||
const sendMessage = async () => {
|
||||
// Empty?
|
||||
if (!newMessage.value.trim()) return
|
||||
// Empty or already sending?
|
||||
if (!newMessage.value.trim() || isSending.value) return
|
||||
|
||||
// Stop typing when sending message
|
||||
stopTyping()
|
||||
|
||||
Reference in New Issue
Block a user