From c27356040854231882640243a99dc2600e3a303d Mon Sep 17 00:00:00 2001 From: eugenijm Date: Mon, 11 May 2020 13:55:06 +0300 Subject: [PATCH] WIP display the last message in the chat list --- src/components/chat_list_item/chat_list_item.scss | 2 +- src/components/chat_list_item/chat_list_item.vue | 5 ++++- src/services/api/api.service.js | 2 +- src/services/entity_normalizer/entity_normalizer.service.js | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/components/chat_list_item/chat_list_item.scss b/src/components/chat_list_item/chat_list_item.scss index ee9054bb..335f133d 100644 --- a/src/components/chat_list_item/chat_list_item.scss +++ b/src/components/chat_list_item/chat_list_item.scss @@ -68,7 +68,7 @@ text-overflow: ellipsis; overflow: hidden; flex: 1; - margin-right: 10px; + margin-right: 15px; } .faint-link { diff --git a/src/components/chat_list_item/chat_list_item.vue b/src/components/chat_list_item/chat_list_item.vue index 1acc49a5..07931759 100644 --- a/src/components/chat_list_item/chat_list_item.vue +++ b/src/components/chat_list_item/chat_list_item.vue @@ -27,7 +27,10 @@
- {{ 'Last message placeholder' }} +
return fetch(url, { headers: authHeaders(credentials) }) .then((data) => data.json()) .then((data) => { - return { chats: data.map(parseChat), pagination } + return { chats: data.map(parseChat).filter(c => c), pagination } }) } diff --git a/src/services/entity_normalizer/entity_normalizer.service.js b/src/services/entity_normalizer/entity_normalizer.service.js index 3d321d65..5f9be7f1 100644 --- a/src/services/entity_normalizer/entity_normalizer.service.js +++ b/src/services/entity_normalizer/entity_normalizer.service.js @@ -376,11 +376,12 @@ export const parseChat = (chat) => { output.id = parseInt(chat.id, 10) output.account = parseUser(chat.account) output.unread = chat.unread - output.lastMessage = undefined + output.lastMessage = parseChatMessage(chat.last_message) return output } export const parseChatMessage = (message) => { + if (!message) { return } let output = message output.id = parseInt(message.id, 10) output.created_at = new Date(message.created_at)