Solve bug with undefined props in lastMessage object

This commit is contained in:
Angela Mazzurco 2017-06-13 14:40:05 +02:00
parent dc02fe034e
commit 0a9c29f0b9

View File

@ -137,7 +137,7 @@ Item
id: lastMessageSender id: lastMessageSender
font.italic: true font.italic: true
color: "royalblue" color: "royalblue"
text: (!lastMessageData.incoming && lastMessageData.msg)? "You: " : "" text: ((lastMessageData && lastMessageData.incoming !== undefined) && !lastMessageData.incoming)? "You: " : ""
height: parent.height height: parent.height
} }
@ -145,7 +145,7 @@ Item
{ {
id: lastMessageMsg id: lastMessageMsg
anchors.left: lastMessageSender.right anchors.left: lastMessageSender.right
text: (lastMessageData.msg) ? lastMessageData.msg : "" text: (lastMessageData && lastMessageData.msg !== undefined)? lastMessageData.msg : ""
rightPadding: 5 rightPadding: 5
elide: Text.ElideRight elide: Text.ElideRight
color: "darkslategrey" color: "darkslategrey"
@ -210,7 +210,7 @@ Item
} }
if (chatId) { if (chatId) {
var last = getChatLastMessage(chatId) var last = getChatLastMessage(chatId)
if (last) lastMessageData = getChatLastMessage(chatId) if (last) lastMessageData = last
} }
} }
@ -237,7 +237,7 @@ Item
return ChatCache.lastMessageCache.getChatIdFromGxs(model.gxs_id) return ChatCache.lastMessageCache.getChatIdFromGxs(model.gxs_id)
} }
function setTime(){ function setTime(){
if (!lastMessageData.recv_time){ if (!lastMessageData || lastMessageData.recv_time === undefined){
return "" return ""
} }
var timeFormat = "dd.MM.yyyy"; var timeFormat = "dd.MM.yyyy";