From a6960dc2d38f64f02eb17af88c59ca3f50a24c48 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?David=20Kube=C5=A1?=
<46596180+KubesDavid@users.noreply.github.com>
Date: Fri, 14 Oct 2022 05:43:11 +0200
Subject: [PATCH] chore: Refactor widget (#5621)
---
app/javascript/widget/api/agent.js | 3 +--
app/javascript/widget/api/campaign.js | 3 +--
app/javascript/widget/api/conversation.js | 12 ++++--------
app/javascript/widget/assets/scss/woot.scss | 5 +----
app/javascript/widget/components/AgentMessage.vue | 3 +--
app/javascript/widget/components/ChatAttachment.vue | 4 ++--
.../widget/components/ChatHeaderExpanded.vue | 7 ++++++-
app/javascript/widget/components/ChatInputWrap.vue | 4 +---
app/javascript/widget/components/FileBubble.vue | 3 +--
app/javascript/widget/components/PreChat/Form.vue | 7 ++-----
.../widget/components/TeamAvailability.vue | 4 ++--
.../widget/components/UnreadMessageList.vue | 3 +--
app/javascript/widget/helpers/IframeEventHelper.js | 2 +-
app/javascript/widget/helpers/utils.js | 11 +----------
.../widget/store/modules/conversation/getters.js | 6 ++----
.../widget/store/modules/conversation/helpers.js | 2 +-
.../widget/store/modules/conversation/mutations.js | 3 +--
.../widget/store/modules/conversationLabels.js | 4 ++--
18 files changed, 31 insertions(+), 55 deletions(-)
diff --git a/app/javascript/widget/api/agent.js b/app/javascript/widget/api/agent.js
index 0debeccaf..5dceecad7 100644
--- a/app/javascript/widget/api/agent.js
+++ b/app/javascript/widget/api/agent.js
@@ -3,6 +3,5 @@ import { API } from 'widget/helpers/axios';
export const getAvailableAgents = async websiteToken => {
const urlData = endPoints.getAvailableAgents(websiteToken);
- const result = await API.get(urlData.url, { params: urlData.params });
- return result;
+ return API.get(urlData.url, { params: urlData.params });
};
diff --git a/app/javascript/widget/api/campaign.js b/app/javascript/widget/api/campaign.js
index 57d81e084..efa154f41 100644
--- a/app/javascript/widget/api/campaign.js
+++ b/app/javascript/widget/api/campaign.js
@@ -3,8 +3,7 @@ import { API } from 'widget/helpers/axios';
const getCampaigns = async websiteToken => {
const urlData = endPoints.getCampaigns(websiteToken);
- const result = await API.get(urlData.url, { params: urlData.params });
- return result;
+ return API.get(urlData.url, { params: urlData.params });
};
const triggerCampaign = async ({
diff --git a/app/javascript/widget/api/conversation.js b/app/javascript/widget/api/conversation.js
index fdb3842fd..4cf4de25e 100755
--- a/app/javascript/widget/api/conversation.js
+++ b/app/javascript/widget/api/conversation.js
@@ -3,26 +3,22 @@ import { API } from 'widget/helpers/axios';
const createConversationAPI = async content => {
const urlData = endPoints.createConversation(content);
- const result = await API.post(urlData.url, urlData.params);
- return result;
+ return API.post(urlData.url, urlData.params);
};
const sendMessageAPI = async content => {
const urlData = endPoints.sendMessage(content);
- const result = await API.post(urlData.url, urlData.params);
- return result;
+ return API.post(urlData.url, urlData.params);
};
const sendAttachmentAPI = async attachment => {
const urlData = endPoints.sendAttachment(attachment);
- const result = await API.post(urlData.url, urlData.params);
- return result;
+ return API.post(urlData.url, urlData.params);
};
const getMessagesAPI = async ({ before }) => {
const urlData = endPoints.getConversation({ before });
- const result = await API.get(urlData.url, { params: urlData.params });
- return result;
+ return API.get(urlData.url, { params: urlData.params });
};
const getConversationAPI = async () => {
diff --git a/app/javascript/widget/assets/scss/woot.scss b/app/javascript/widget/assets/scss/woot.scss
index 9a2a6a8e6..3f882eb38 100755
--- a/app/javascript/widget/assets/scss/woot.scss
+++ b/app/javascript/widget/assets/scss/woot.scss
@@ -61,10 +61,7 @@ body {
.is-flat-design {
.chat-bubble {
- border-bottom-left-radius: 0 !important;
- border-bottom-right-radius: 0 !important;
- border-top-left-radius: 0 !important;
- border-top-right-radius: 0 !important;
+ border-radius: 0 !important;
box-shadow: none;
}
diff --git a/app/javascript/widget/components/AgentMessage.vue b/app/javascript/widget/components/AgentMessage.vue
index c338dce83..6b1fb782b 100755
--- a/app/javascript/widget/components/AgentMessage.vue
+++ b/app/javascript/widget/components/AgentMessage.vue
@@ -104,8 +104,7 @@ export default {
) {
return false;
}
- if (!this.message.content) return false;
- return true;
+ return this.message.content;
},
readableTime() {
const { created_at: createdAt = '' } = this.message;
diff --git a/app/javascript/widget/components/ChatAttachment.vue b/app/javascript/widget/components/ChatAttachment.vue
index 87da3f5df..0412ca5fb 100755
--- a/app/javascript/widget/components/ChatAttachment.vue
+++ b/app/javascript/widget/components/ChatAttachment.vue
@@ -54,9 +54,9 @@ export default {
},
async onFileUpload(file) {
if (this.globalConfig.directUploadsEnabled) {
- this.onDirectFileUpload(file);
+ await this.onDirectFileUpload(file);
} else {
- this.onIndirectFileUpload(file);
+ await this.onIndirectFileUpload(file);
}
},
async onDirectFileUpload(file) {
diff --git a/app/javascript/widget/components/ChatHeaderExpanded.vue b/app/javascript/widget/components/ChatHeaderExpanded.vue
index c1823f504..f82f66c46 100755
--- a/app/javascript/widget/components/ChatHeaderExpanded.vue
+++ b/app/javascript/widget/components/ChatHeaderExpanded.vue
@@ -7,7 +7,12 @@
class="flex items-start"
:class="[avatarUrl ? 'justify-between' : 'justify-end']"
>
-
+