2019-03-22 14:28:14 +11:00
|
|
|
import QtQuick 2.7
|
|
|
|
import QtQuick.Controls 2.0
|
|
|
|
import QtQuick.Layouts 1.4
|
2019-03-26 20:52:43 +11:00
|
|
|
import "../base" as Base
|
2019-03-22 14:28:14 +11:00
|
|
|
|
|
|
|
Column {
|
2019-04-18 06:43:18 +10:00
|
|
|
id: "rootCol"
|
2019-03-22 14:28:14 +11:00
|
|
|
|
|
|
|
function mins_between(date1, date2) {
|
2019-04-18 06:43:18 +10:00
|
|
|
console.log(Math.round((((date2 - date1) % 86400000) % 3600000) / 60000))
|
2019-03-22 14:28:14 +11:00
|
|
|
return Math.round((((date2 - date1) % 86400000) % 3600000) / 60000)
|
|
|
|
}
|
|
|
|
|
2019-04-18 06:43:18 +10:00
|
|
|
function is_message(type_) { return type_.startsWith("RoomMessage") }
|
|
|
|
|
|
|
|
readonly property var previousItem:
|
|
|
|
index < messageListView.model.count - 1 ?
|
|
|
|
messageListView.model.get(index + 1) : null
|
|
|
|
|
|
|
|
readonly property bool isMessage: is_message(type)
|
2019-04-15 02:56:30 +10:00
|
|
|
|
|
|
|
readonly property bool isUndecryptableEvent:
|
|
|
|
type === "OlmEvent" || type === "MegolmEvent"
|
|
|
|
|
2019-03-22 14:28:14 +11:00
|
|
|
readonly property string displayName:
|
2019-04-15 02:56:30 +10:00
|
|
|
Backend.getUser(dict.sender).display_name
|
2019-03-22 14:28:14 +11:00
|
|
|
|
|
|
|
readonly property bool isOwn:
|
2019-04-15 02:56:30 +10:00
|
|
|
chatPage.user_id === dict.sender
|
2019-03-22 14:28:14 +11:00
|
|
|
|
2019-04-18 06:43:18 +10:00
|
|
|
readonly property bool isFirstMessage: ! previousItem
|
2019-03-22 14:28:14 +11:00
|
|
|
|
|
|
|
readonly property bool combine:
|
|
|
|
! isFirstMessage &&
|
2019-04-18 06:43:18 +10:00
|
|
|
! talkBreak &&
|
|
|
|
! dayBreak &&
|
|
|
|
is_message(previousItem.type) === isMessage &&
|
|
|
|
previousItem.dict.sender === dict.sender &&
|
|
|
|
mins_between(previousItem.date_time, date_time) <= 5
|
2019-03-22 14:28:14 +11:00
|
|
|
|
|
|
|
readonly property bool dayBreak:
|
|
|
|
isFirstMessage ||
|
2019-04-18 06:43:18 +10:00
|
|
|
date_time.getDay() != previousItem.date_time.getDay()
|
2019-03-22 14:28:14 +11:00
|
|
|
|
|
|
|
readonly property bool talkBreak:
|
|
|
|
! isFirstMessage &&
|
|
|
|
! dayBreak &&
|
2019-04-18 06:43:18 +10:00
|
|
|
mins_between(previousItem.date_time, date_time) >= 20
|
2019-03-22 14:28:14 +11:00
|
|
|
|
|
|
|
|
2019-04-18 06:43:18 +10:00
|
|
|
property int standardSpacing: 16
|
2019-03-22 14:28:14 +11:00
|
|
|
property int horizontalPadding: 7
|
|
|
|
property int verticalPadding: 5
|
|
|
|
|
|
|
|
width: parent.width
|
|
|
|
topPadding:
|
2019-04-18 06:43:18 +10:00
|
|
|
! previousItem ? 0 :
|
|
|
|
talkBreak ? standardSpacing * 3 :
|
|
|
|
combine ? standardSpacing / 4 :
|
|
|
|
standardSpacing
|
|
|
|
|
|
|
|
//Text { text: rootCol.topPadding }
|
2019-03-22 14:28:14 +11:00
|
|
|
|
2019-03-26 20:52:43 +11:00
|
|
|
Daybreak { visible: dayBreak }
|
2019-03-22 14:28:14 +11:00
|
|
|
|
2019-04-15 04:09:54 +10:00
|
|
|
MessageContent { visible: isMessage }
|
2019-03-22 14:28:14 +11:00
|
|
|
|
2019-04-15 04:09:54 +10:00
|
|
|
EventContent { visible: ! isMessage }
|
2019-03-22 14:28:14 +11:00
|
|
|
}
|