parent
e68333fb07
commit
10fd90a152
|
@ -298,8 +298,8 @@ ScrollView {
|
|||
prevMessageIndex: {
|
||||
// This is used in order to have access to the previous message and determine the timestamp
|
||||
// we can't rely on the index because the sequence of messages is not ordered on the nim side
|
||||
if(msgDelegate.DelegateModel.itemsIndex > 0){
|
||||
return messageListDelegate.items.get(msgDelegate.DelegateModel.itemsIndex - 1).model.index
|
||||
if (msgDelegate.DelegateModel.itemsIndex < messageListDelegate.items.count - 1) {
|
||||
return messageListDelegate.items.get(msgDelegate.DelegateModel.itemsIndex + 1).model.index
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ Item {
|
|||
property bool isCurrentUser: false
|
||||
property bool isHovered: false
|
||||
property bool isMessageActive: false
|
||||
property bool headerRepeatCondition: (authorCurrentMsg !== authorPrevMsg || shouldRepeatHeader || dateGroupLbl.visible)
|
||||
|
||||
id: root
|
||||
|
||||
|
@ -72,7 +73,7 @@ Item {
|
|||
|
||||
UserImage {
|
||||
id: chatImage
|
||||
active: isMessage && authorCurrentMsg != authorPrevMsg
|
||||
active: isMessage && headerRepeatCondition
|
||||
anchors.left: parent.left
|
||||
anchors.leftMargin: Style.current.padding
|
||||
anchors.top: parent.top
|
||||
|
@ -81,6 +82,7 @@ Item {
|
|||
|
||||
UsernameLabel {
|
||||
id: chatName
|
||||
visible: isMessage && headerRepeatCondition
|
||||
anchors.leftMargin: root.chatHorizontalPadding
|
||||
anchors.top: chatImage.top
|
||||
anchors.left: chatImage.right
|
||||
|
@ -88,7 +90,7 @@ Item {
|
|||
|
||||
ChatTime {
|
||||
id: chatTime
|
||||
visible: authorCurrentMsg != authorPrevMsg
|
||||
visible: headerRepeatCondition
|
||||
anchors.verticalCenter: chatName.verticalCenter
|
||||
anchors.left: chatName.right
|
||||
anchors.leftMargin: 4
|
||||
|
|
|
@ -5,7 +5,7 @@ import "../../../../../imports"
|
|||
StyledText {
|
||||
id: dateGroupLbl
|
||||
font.pixelSize: 13
|
||||
color: Style.current.darkGrey
|
||||
color: Style.current.secondaryText
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
text: {
|
||||
|
@ -15,49 +15,48 @@ StyledText {
|
|||
let yesterday = new Date()
|
||||
yesterday.setDate(now.getDate()-1)
|
||||
|
||||
let prevMsgTimestamp = chatsModel.messageList.getMessageData(prevMessageIndex, "timestamp")
|
||||
var currentMsgDate = new Date(parseInt(timestamp, 10));
|
||||
var prevMsgDate = prevMsgTimestamp === "" ? new Date(0) : new Date(parseInt(prevMsgTimestamp, 10));
|
||||
if(currentMsgDate.getDay() !== prevMsgDate.getDay()){
|
||||
if (now.toDateString() === currentMsgDate.toDateString()) {
|
||||
//% "Today"
|
||||
return qsTrId("today")
|
||||
} else if (yesterday.toDateString() === currentMsgDate.toDateString()) {
|
||||
//% "Yesterday"
|
||||
return qsTrId("yesterday")
|
||||
} else {
|
||||
const monthNames = [
|
||||
//% "January"
|
||||
qsTrId("january"),
|
||||
//% "February"
|
||||
qsTrId("february"),
|
||||
//% "March"
|
||||
qsTrId("march"),
|
||||
//% "April"
|
||||
qsTrId("april"),
|
||||
//% "May"
|
||||
qsTrId("may"),
|
||||
//% "June"
|
||||
qsTrId("june"),
|
||||
//% "July"
|
||||
qsTrId("july"),
|
||||
//% "August"
|
||||
qsTrId("august"),
|
||||
//% "September"
|
||||
qsTrId("september"),
|
||||
//% "October"
|
||||
qsTrId("october"),
|
||||
//% "November"
|
||||
qsTrId("november"),
|
||||
//% "December"
|
||||
qsTrId("december")
|
||||
];
|
||||
return monthNames[currentMsgDate.getMonth()] + ", " + currentMsgDate.getDate()
|
||||
}
|
||||
} else {
|
||||
return "";
|
||||
|
||||
if (currentMsgDate.getDay() === prevMsgDate.getDay()) {
|
||||
return ""
|
||||
}
|
||||
|
||||
if (now.toDateString() === currentMsgDate.toDateString()) {
|
||||
//% "Today"
|
||||
return qsTrId("today")
|
||||
} else if (yesterday.toDateString() === currentMsgDate.toDateString()) {
|
||||
//% "Yesterday"
|
||||
return qsTrId("yesterday")
|
||||
} else {
|
||||
const monthNames = [
|
||||
//% "January"
|
||||
qsTrId("january"),
|
||||
//% "February"
|
||||
qsTrId("february"),
|
||||
//% "March"
|
||||
qsTrId("march"),
|
||||
//% "April"
|
||||
qsTrId("april"),
|
||||
//% "May"
|
||||
qsTrId("may"),
|
||||
//% "June"
|
||||
qsTrId("june"),
|
||||
//% "July"
|
||||
qsTrId("july"),
|
||||
//% "August"
|
||||
qsTrId("august"),
|
||||
//% "September"
|
||||
qsTrId("september"),
|
||||
//% "October"
|
||||
qsTrId("october"),
|
||||
//% "November"
|
||||
qsTrId("november"),
|
||||
//% "December"
|
||||
qsTrId("december")
|
||||
];
|
||||
return monthNames[currentMsgDate.getMonth()] + ", " + currentMsgDate.getDate()
|
||||
}
|
||||
}
|
||||
visible: text !== ""
|
||||
anchors.top: parent.top
|
||||
|
|
|
@ -22,7 +22,7 @@ Item {
|
|||
|
||||
UserImage {
|
||||
id: chatImage
|
||||
visible: chatsModel.activeChannel.chatType !== Constants.chatTypeOneToOne && isMessage && headerRepeatCondition && !root.isCurrentUser
|
||||
active: chatsModel.activeChannel.chatType !== Constants.chatTypeOneToOne && isMessage && headerRepeatCondition && !root.isCurrentUser
|
||||
anchors.left: parent.left
|
||||
anchors.leftMargin: Style.current.padding
|
||||
anchors.top: dateGroupLbl.visible ? dateGroupLbl.bottom : parent.top
|
||||
|
|
Loading…
Reference in New Issue