From d65c5a1d292d1e1dd0c36c5e3cbd22a388628c15 Mon Sep 17 00:00:00 2001 From: Mary Kate Date: Thu, 10 Sep 2020 11:07:32 -0500 Subject: [PATCH] add author data to messages in chat show --- src/components/ChatMessage/index.vue | 17 +++++++++++++ src/store/modules/chat.js | 4 +-- src/views/chats/show.vue | 37 +++++++++++++++++++++------- src/views/users/show.vue | 8 +++--- 4 files changed, 50 insertions(+), 16 deletions(-) diff --git a/src/components/ChatMessage/index.vue b/src/components/ChatMessage/index.vue index b23325aa..400ec205 100644 --- a/src/components/ChatMessage/index.vue +++ b/src/components/ChatMessage/index.vue @@ -2,6 +2,16 @@
+
+ + + + + + +
{{ message.created_at }}
@@ -21,6 +31,10 @@ export default { type: Object, required: true }, + author: { + type: Object, + required: true + }, page: { type: Number, required: false, @@ -32,6 +46,9 @@ export default { } }, methods: { + propertyExists(account, property) { + return account[property] + } } } diff --git a/src/store/modules/chat.js b/src/store/modules/chat.js index 0cee17d1..5a78093f 100644 --- a/src/store/modules/chat.js +++ b/src/store/modules/chat.js @@ -4,8 +4,7 @@ const chat = { state: { fetchedChat: {}, fetchedChatMessages: {}, - loading: false, - chatAuthor: {} + loading: false }, mutations: { SET_LOADING: (state, status) => { @@ -29,7 +28,6 @@ const chat = { async FetchChatMessages({ commit, dispatch, getters, state }, id) { commit('SET_LOADING', true) const chat = await fetchChatMessages(id, getters.authHost, getters.token) - commit('SET_CHAT_MESSAGES', chat.data) commit('SET_LOADING', false) } diff --git a/src/views/chats/show.vue b/src/views/chats/show.vue index be99d0f4..5ca80032 100644 --- a/src/views/chats/show.vue +++ b/src/views/chats/show.vue @@ -15,19 +15,33 @@

{{ $t('chats.chatHistory') }}

- +
+
+ + + + + + +
+
+ + + + + + +
+
- +
@@ -76,6 +90,11 @@ export default { methods: { propertyExists(account, property) { return account[property] + }, + getAuthor(account_id) { + const sender = this.chat.sender + const receiver = this.chat.receiver + return account_id === sender.id ? sender : receiver } } } diff --git a/src/views/users/show.vue b/src/views/users/show.vue index 1a57582b..ae926d6a 100644 --- a/src/views/users/show.vue +++ b/src/views/users/show.vue @@ -122,11 +122,11 @@
- - + + -