mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-02 20:18:08 +00:00
feat: Update bot typing indicator based on the conversation status (#7714)
- Show the indicator if the last message is incoming and the conversation is in pending status. - Remove list of articles displayed in the bot response.
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
<div class="agent-message-wrap">
|
<div class="agent-message-wrap">
|
||||||
<div class="agent-message">
|
<div class="agent-message">
|
||||||
<div class="avatar-wrap" />
|
<div class="avatar-wrap" />
|
||||||
<div class="message-wrap">
|
<div class="message-wrap mt-2">
|
||||||
<div
|
<div
|
||||||
class="typing-bubble chat-bubble agent"
|
class="typing-bubble chat-bubble agent"
|
||||||
:class="$dm('bg-white', 'dark:bg-slate-50')"
|
:class="$dm('bg-white', 'dark:bg-slate-50')"
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
:message="message"
|
:message="message"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<agent-typing-bubble v-if="isAgentTyping" />
|
<agent-typing-bubble v-if="showStatusIndicator" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -27,7 +27,7 @@ import AgentTypingBubble from 'widget/components/AgentTypingBubble.vue';
|
|||||||
import DateSeparator from 'shared/components/DateSeparator.vue';
|
import DateSeparator from 'shared/components/DateSeparator.vue';
|
||||||
import Spinner from 'shared/components/Spinner.vue';
|
import Spinner from 'shared/components/Spinner.vue';
|
||||||
import darkModeMixin from 'widget/mixins/darkModeMixin';
|
import darkModeMixin from 'widget/mixins/darkModeMixin';
|
||||||
|
import { MESSAGE_TYPE } from 'shared/constants/messages';
|
||||||
import { mapActions, mapGetters } from 'vuex';
|
import { mapActions, mapGetters } from 'vuex';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@@ -54,14 +54,26 @@ export default {
|
|||||||
computed: {
|
computed: {
|
||||||
...mapGetters({
|
...mapGetters({
|
||||||
earliestMessage: 'conversation/getEarliestMessage',
|
earliestMessage: 'conversation/getEarliestMessage',
|
||||||
|
lastMessage: 'conversation/getLastMessage',
|
||||||
allMessagesLoaded: 'conversation/getAllMessagesLoaded',
|
allMessagesLoaded: 'conversation/getAllMessagesLoaded',
|
||||||
isFetchingList: 'conversation/getIsFetchingList',
|
isFetchingList: 'conversation/getIsFetchingList',
|
||||||
conversationSize: 'conversation/getConversationSize',
|
conversationSize: 'conversation/getConversationSize',
|
||||||
isAgentTyping: 'conversation/getIsAgentTyping',
|
isAgentTyping: 'conversation/getIsAgentTyping',
|
||||||
|
conversationAttributes: 'conversationAttributes/getConversationParams',
|
||||||
}),
|
}),
|
||||||
colorSchemeClass() {
|
colorSchemeClass() {
|
||||||
return `${this.darkMode === 'dark' ? 'dark-scheme' : 'light-scheme'}`;
|
return `${this.darkMode === 'dark' ? 'dark-scheme' : 'light-scheme'}`;
|
||||||
},
|
},
|
||||||
|
showStatusIndicator() {
|
||||||
|
const { status } = this.conversationAttributes;
|
||||||
|
const isConversationInPendingStatus = status === 'pending';
|
||||||
|
const isLastMessageIncoming =
|
||||||
|
this.lastMessage.message_type === MESSAGE_TYPE.INCOMING;
|
||||||
|
return (
|
||||||
|
this.isAgentTyping ||
|
||||||
|
(isConversationInPendingStatus && isLastMessageIncoming)
|
||||||
|
);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
allMessagesLoaded() {
|
allMessagesLoaded() {
|
||||||
|
|||||||
@@ -16,6 +16,13 @@ export const getters = {
|
|||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
},
|
},
|
||||||
|
getLastMessage: _state => {
|
||||||
|
const conversation = Object.values(_state.conversations);
|
||||||
|
if (conversation.length) {
|
||||||
|
return conversation[conversation.length - 1];
|
||||||
|
}
|
||||||
|
return {};
|
||||||
|
},
|
||||||
getGroupedConversation: _state => {
|
getGroupedConversation: _state => {
|
||||||
const conversationGroupedByDate = groupBy(
|
const conversationGroupedByDate = groupBy(
|
||||||
Object.values(_state.conversations),
|
Object.values(_state.conversations),
|
||||||
|
|||||||
@@ -61,9 +61,8 @@ class Enterprise::MessageTemplates::ResponseBotService
|
|||||||
end
|
end
|
||||||
|
|
||||||
def create_messages(response, conversation)
|
def create_messages(response, conversation)
|
||||||
response, article_ids = process_response_content(response)
|
response = process_response_content(response)
|
||||||
create_outgoing_message(response, conversation)
|
create_outgoing_message(response, conversation)
|
||||||
create_outgoing_message_with_cards(article_ids, conversation) if article_ids.present?
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def process_response_content(response)
|
def process_response_content(response)
|
||||||
|
|||||||
Reference in New Issue
Block a user