WIP display the last message in the chat list
This commit is contained in:
parent
0f3c667eb8
commit
c273560408
4 changed files with 8 additions and 4 deletions
|
@ -68,7 +68,7 @@
|
|||
text-overflow: ellipsis;
|
||||
overflow: hidden;
|
||||
flex: 1;
|
||||
margin-right: 10px;
|
||||
margin-right: 15px;
|
||||
}
|
||||
|
||||
.faint-link {
|
||||
|
|
|
@ -27,7 +27,10 @@
|
|||
</div>
|
||||
<!-- eslint-disable vue/no-v-html -->
|
||||
<div class="chat-preview">
|
||||
{{ 'Last message placeholder' }}
|
||||
<span
|
||||
class="content"
|
||||
v-html="chat.lastMessage && chat.lastMessage.content"
|
||||
/>
|
||||
<div
|
||||
v-if="chat.unread > 0"
|
||||
class="alert-dot-number"
|
||||
|
|
|
@ -1138,7 +1138,7 @@ const chats = ({ maxId, sinceId, limit = 20, recipients = [], credentials }) =>
|
|||
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 }
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue