change the message fetch model. the client should cache the historical data locally, and fetch latest data with a timestamp, to improve the performance
This commit is contained in:
parent
af64b01d84
commit
37f5f0b88c
@ -8,8 +8,8 @@
|
|||||||
class="conversation-container"
|
class="conversation-container"
|
||||||
:class="{
|
:class="{
|
||||||
selected:
|
selected:
|
||||||
current_thread?.conversation?.information?.id ===
|
current_thread?.conversation?.id ===
|
||||||
conversation.summary.last_message?.conversation_id
|
conversation.id
|
||||||
}"
|
}"
|
||||||
@click="selectConversation(conversation)"
|
@click="selectConversation(conversation)"
|
||||||
>
|
>
|
||||||
@ -17,17 +17,16 @@
|
|||||||
<div class="conversation-summary-container">
|
<div class="conversation-summary-container">
|
||||||
<div class="conversation-summary-header-container">
|
<div class="conversation-summary-header-container">
|
||||||
<span class="participant-fullname">
|
<span class="participant-fullname">
|
||||||
{{ conversation.summary.contact.first_name }}
|
{{ conversation.subject }}
|
||||||
{{ conversation.summary.contact.last_name }}
|
|
||||||
</span>
|
</span>
|
||||||
<span class="conversation-last-update-date">{{
|
<span class="conversation-last-update-date">{{
|
||||||
getDateFromFulltimeString(conversation.summary.last_message?.create_time)
|
getDateFromFulltimeString(conversation.create_time)
|
||||||
}}</span>
|
}}</span>
|
||||||
<!-- <span v-if="unreadCountMapper()" class="conversation-unreadcount">2</span> -->
|
<!-- <span v-if="unreadCountMapper()" class="conversation-unreadcount">2</span> -->
|
||||||
</div>
|
</div>
|
||||||
<div class="conversation-summary-highlight-container">
|
<!-- <div class="conversation-summary-highlight-container">
|
||||||
{{ conversation.summary.last_message?.message_body }}
|
{{ conversation.summary.last_message?.message_body }}
|
||||||
</div>
|
</div> -->
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -86,14 +85,14 @@ export default {
|
|||||||
name: 'MessageHub',
|
name: 'MessageHub',
|
||||||
props: {},
|
props: {},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.fetchMessageThreads()
|
this.fetchConversations()
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
conversations: {
|
conversations: {
|
||||||
handler: function (val) {
|
handler: function (val) {
|
||||||
if (val && val.length > 0) {
|
if (val && val.length > 0) {
|
||||||
this.current_thread = val[0]
|
//this.current_thread = val[0]
|
||||||
this.clearUnreadMessageBy(val[0])
|
//this.clearUnreadMessageBy(val[0])
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
deep: false
|
deep: false
|
||||||
@ -113,10 +112,27 @@ export default {
|
|||||||
// }
|
// }
|
||||||
// },
|
// },
|
||||||
methods: {
|
methods: {
|
||||||
fetchMessageThreads() {
|
fetchConversations() {
|
||||||
MessageHubApi.fetchMessageThreads()
|
MessageHubApi.fetchConversations(new Date('01 Jan 1970 00:00:00 GMT').toISOString())
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
this.conversations = response.data
|
this.conversations = response.data.conversations
|
||||||
|
//TEST
|
||||||
|
this.conversations.forEach((conversation) => {
|
||||||
|
this.fetchMessageForConversation(conversation.id)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
this.mnx_backendErrorHandler(error)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
fetchMessageForConversation(conversation_id) {
|
||||||
|
MessageHubApi.fetchMessages(
|
||||||
|
conversation_id,
|
||||||
|
new Date('01 Jan 1975 00:00:00 GMT').toISOString()
|
||||||
|
)
|
||||||
|
.then((response) => {
|
||||||
|
messages = response.data
|
||||||
|
console.log('Received message for conversation:', conversation_id)
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
this.mnx_backendErrorHandler(error)
|
this.mnx_backendErrorHandler(error)
|
||||||
@ -157,6 +173,7 @@ export default {
|
|||||||
height: $body-height;
|
height: $body-height;
|
||||||
padding: 24px 24px 0 24px;
|
padding: 24px 24px 0 24px;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
|
||||||
.message-hub-conainter {
|
.message-hub-conainter {
|
||||||
display: flex;
|
display: flex;
|
||||||
box-shadow: 0px 0px 24px 0px #d4d3e380;
|
box-shadow: 0px 0px 24px 0px #d4d3e380;
|
||||||
@ -165,32 +182,38 @@ export default {
|
|||||||
max-width: $body-width;
|
max-width: $body-width;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
|
||||||
.conversation-list-container {
|
.conversation-list-container {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
width: 300px;
|
width: 300px;
|
||||||
|
|
||||||
.conversation-container {
|
.conversation-container {
|
||||||
background-color: #f3f3f5;
|
background-color: #f3f3f5;
|
||||||
display: flex;
|
display: flex;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
height: 98px;
|
height: 98px;
|
||||||
padding: 18px;
|
padding: 18px;
|
||||||
|
|
||||||
.participant-portrait {
|
.participant-portrait {
|
||||||
width: 36px;
|
width: 36px;
|
||||||
height: 36px;
|
height: 36px;
|
||||||
border-radius: 18px;
|
border-radius: 18px;
|
||||||
margin-right: 16px;
|
margin-right: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.conversation-summary-container {
|
.conversation-summary-container {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
flex: 1;
|
flex: 1;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
|
||||||
.conversation-summary-header-container {
|
.conversation-summary-header-container {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
height: 22px;
|
height: 22px;
|
||||||
color: #0d1637;
|
color: #0d1637;
|
||||||
|
|
||||||
.participant-fullname {
|
.participant-fullname {
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
flex: 1;
|
flex: 1;
|
||||||
@ -198,10 +221,12 @@ export default {
|
|||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
.conversation-last-update-date {
|
.conversation-last-update-date {
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.conversation-unreadcount {
|
.conversation-unreadcount {
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
background: red;
|
background: red;
|
||||||
@ -216,6 +241,7 @@ export default {
|
|||||||
margin-left: 10px;
|
margin-left: 10px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.conversation-summary-highlight-container {
|
.conversation-summary-highlight-container {
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
color: #6e7387;
|
color: #6e7387;
|
||||||
@ -226,14 +252,17 @@ export default {
|
|||||||
word-break: break-word;
|
word-break: break-word;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
opacity: 0.78;
|
opacity: 0.78;
|
||||||
}
|
}
|
||||||
|
|
||||||
&.selected {
|
&.selected {
|
||||||
background-color: transparent;
|
background-color: transparent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.conversation-list-empty-container {
|
.conversation-list-empty-container {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
@ -243,24 +272,28 @@ export default {
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.message-panel-container {
|
.message-panel-container {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
flex: 1;
|
flex: 1;
|
||||||
padding-bottom: 98px;
|
padding-bottom: 98px;
|
||||||
position: relative;
|
position: relative;
|
||||||
|
|
||||||
.message-thread-container {
|
.message-thread-container {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
padding: 20px 32px;
|
padding: 20px 32px;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
|
||||||
.message-item-container {
|
.message-item-container {
|
||||||
max-width: 70%;
|
max-width: 70%;
|
||||||
margin-bottom: 15px;
|
margin-bottom: 15px;
|
||||||
width: fit-content;
|
width: fit-content;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
|
||||||
.message-item-header-container {
|
.message-item-header-container {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@ -270,11 +303,13 @@ export default {
|
|||||||
font-size: 18px;
|
font-size: 18px;
|
||||||
width: fit-content;
|
width: fit-content;
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
|
|
||||||
.message-item-sender-portrait {
|
.message-item-sender-portrait {
|
||||||
width: 36px;
|
width: 36px;
|
||||||
height: 36px;
|
height: 36px;
|
||||||
border-radius: 18px;
|
border-radius: 18px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.message-item-sender-fullname {
|
.message-item-sender-fullname {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
@ -283,6 +318,7 @@ export default {
|
|||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
margin: 0 7px;
|
margin: 0 7px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.message-item-create-time {
|
.message-item-create-time {
|
||||||
color: #737478;
|
color: #737478;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
@ -290,6 +326,7 @@ export default {
|
|||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.message-item-message-body {
|
.message-item-message-body {
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
line-height: 17px;
|
line-height: 17px;
|
||||||
@ -306,10 +343,12 @@ export default {
|
|||||||
|
|
||||||
&.me {
|
&.me {
|
||||||
align-self: flex-end;
|
align-self: flex-end;
|
||||||
|
|
||||||
.message-item-header-container {
|
.message-item-header-container {
|
||||||
flex-direction: row-reverse;
|
flex-direction: row-reverse;
|
||||||
align-self: flex-end;
|
align-self: flex-end;
|
||||||
}
|
}
|
||||||
|
|
||||||
.message-item-message-body {
|
.message-item-message-body {
|
||||||
background-color: $primary;
|
background-color: $primary;
|
||||||
color: white;
|
color: white;
|
||||||
@ -318,6 +357,7 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.message-thread-empty-container {
|
.message-thread-empty-container {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
@ -326,6 +366,7 @@ export default {
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.message-writing-panel-container {
|
.message-writing-panel-container {
|
||||||
height: 98px;
|
height: 98px;
|
||||||
padding: 24px;
|
padding: 24px;
|
||||||
@ -334,6 +375,7 @@ export default {
|
|||||||
bottom: 0;
|
bottom: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|
||||||
.writing-message-enter {
|
.writing-message-enter {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
height: 24px;
|
height: 24px;
|
||||||
@ -345,6 +387,7 @@ export default {
|
|||||||
right: 37px;
|
right: 37px;
|
||||||
border-radius: 7px;
|
border-radius: 7px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.writing-message-input {
|
.writing-message-input {
|
||||||
height: 50px;
|
height: 50px;
|
||||||
border: 1px solid #e1e1e1;
|
border: 1px solid #e1e1e1;
|
||||||
|
|||||||
@ -2,11 +2,27 @@ import { backendAxios } from './axios'
|
|||||||
import { userUtils } from '../store/index'
|
import { userUtils } from '../store/index'
|
||||||
|
|
||||||
class MessageHubApi {
|
class MessageHubApi {
|
||||||
static fetchMessageThreads() {
|
static fetchConversations(last_update_time) {
|
||||||
let jwt = userUtils.getJwtToken()
|
let jwt = userUtils.getJwtToken()
|
||||||
const request = backendAxios.post(
|
const request = backendAxios.post(
|
||||||
'/api/messages/fetch-message-threads-for-user',
|
'/api/messages/fetch-conversations-for-user',
|
||||||
{},
|
{
|
||||||
|
last_update_time: last_update_time
|
||||||
|
},
|
||||||
|
{
|
||||||
|
headers: { Authorization: `Bearer ${jwt}` }
|
||||||
|
}
|
||||||
|
)
|
||||||
|
return request
|
||||||
|
}
|
||||||
|
static fetchMessages(conversation_id, last_update_time) {
|
||||||
|
let jwt = userUtils.getJwtToken()
|
||||||
|
const request = backendAxios.post(
|
||||||
|
'/api/messages/fetch-message-thread-for-conversation',
|
||||||
|
{
|
||||||
|
conversation_id: conversation_id,
|
||||||
|
last_update_time: last_update_time
|
||||||
|
},
|
||||||
{
|
{
|
||||||
headers: { Authorization: `Bearer ${jwt}` }
|
headers: { Authorization: `Bearer ${jwt}` }
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user