mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-01-28 01:09:19 +00:00
Fix ordering messages
This commit is contained in:
parent
d8126fbb75
commit
7f3dc8e928
8 changed files with 20 additions and 18 deletions
|
|
@ -41,7 +41,7 @@ ChatCallModel::ChatCallModel ( std::shared_ptr<linphone::CallLog> callLog, const
|
|||
}else{
|
||||
mTimestamp = QDateTime::fromMSecsSinceEpoch((callLog->getStartDate() + callLog->getDuration()) * 1000);
|
||||
if(hasReceived)
|
||||
mReceivedTimestamp = QDateTime::fromMSecsSinceEpoch((mCallLog->getData<time_t>("receivedTime") + callLog->getDuration()) * 1000);
|
||||
mReceivedTimestamp = QDateTime::fromMSecsSinceEpoch(mCallLog->getData<time_t>("receivedTime") + (callLog->getDuration() * 1000));
|
||||
else
|
||||
mReceivedTimestamp = mTimestamp;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -111,11 +111,11 @@ ChatMessageModel::ChatMessageModel ( std::shared_ptr<linphone::ChatMessage> chat
|
|||
mTimestamp = QDateTime::fromMSecsSinceEpoch(chatMessage->getTime() * 1000);
|
||||
auto appdata = ChatMessageModel::AppDataManager(QString::fromStdString(chatMessage->getAppdata()));
|
||||
if(!appdata.mData.contains("receivedTime")){
|
||||
appdata.mData["receivedTime"] = QString::number(mTimestamp.toSecsSinceEpoch());
|
||||
mReceivedTimestamp = QDateTime::currentDateTime();
|
||||
appdata.mData["receivedTime"] = QString::number(mReceivedTimestamp.toMSecsSinceEpoch());
|
||||
chatMessage->setAppdata(Utils::appStringToCoreString(appdata.toString()));
|
||||
mReceivedTimestamp = mTimestamp;
|
||||
}else
|
||||
mReceivedTimestamp = QDateTime::fromMSecsSinceEpoch(appdata.mData["receivedTime"].toULongLong() * 1000);
|
||||
mReceivedTimestamp = QDateTime::fromMSecsSinceEpoch(appdata.mData["receivedTime"].toULongLong());
|
||||
}
|
||||
mWasDownloaded = false;
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ ChatNoticeModel::ChatNoticeModel ( std::shared_ptr<linphone::EventLog> eventLog,
|
|||
setEventLogType(LinphoneEnums::fromLinphone(mEventLog->getType()));
|
||||
mTimestamp = QDateTime::fromMSecsSinceEpoch(eventLog->getCreationTime() * 1000);
|
||||
if(mEventLog->dataExists("receivedTime"))
|
||||
mReceivedTimestamp = QDateTime::fromMSecsSinceEpoch(mEventLog->getData<time_t>("receivedTime") * 1000);
|
||||
mReceivedTimestamp = QDateTime::fromMSecsSinceEpoch(mEventLog->getData<time_t>("receivedTime"));
|
||||
else
|
||||
mReceivedTimestamp = mTimestamp;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -188,7 +188,8 @@ bool ChatRoomProxyModel::lessThan (const QModelIndex &left, const QModelIndex &r
|
|||
return true;
|
||||
if(!a)
|
||||
return false;
|
||||
return a->getReceivedTimestamp() < b->getReceivedTimestamp();
|
||||
return a->getReceivedTimestamp() < b->getReceivedTimestamp() ||
|
||||
(a->getReceivedTimestamp() == b->getReceivedTimestamp() && a->getTimestamp() < b->getTimestamp());
|
||||
}
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
|
@ -288,6 +289,7 @@ void ChatRoomProxyModel::reload (ChatRoomModel *chatRoomModel) {
|
|||
|
||||
mChatRoomModel = CoreManager::getInstance()->getTimelineListModel()->getChatRoomModel(chatRoomModel);
|
||||
setSourceModel(mChatRoomModel.get());
|
||||
sort(0);
|
||||
if (mChatRoomModel) {
|
||||
|
||||
ChatRoomModel *ChatRoomModel = mChatRoomModel.get();
|
||||
|
|
|
|||
|
|
@ -233,7 +233,7 @@ void CoreHandlers::onMessagesReceived (
|
|||
auto chatRoom = message->getChatRoom();
|
||||
auto dbMessage = chatRoom->findMessage(message->getMessageId());
|
||||
auto appdata = ChatMessageModel::AppDataManager(QString::fromStdString(dbMessage->getAppdata()));
|
||||
appdata.mData["receivedTime"] = QString::number(QDateTime::currentMSecsSinceEpoch()/1000);
|
||||
appdata.mData["receivedTime"] = QString::number(QDateTime::currentMSecsSinceEpoch());
|
||||
dbMessage->setAppdata(Utils::appStringToCoreString(appdata.toString()));
|
||||
}
|
||||
if( !message || message->isOutgoing() )
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ static inline void fillCallStartEntry (QVariantMap &dest, const shared_ptr<linph
|
|||
dest["type"] = HistoryModel::CallEntry;
|
||||
dest["timestamp"] = QDateTime::fromMSecsSinceEpoch(callLog->getStartDate() * 1000);
|
||||
if(callLog->dataExists("receivedTime"))
|
||||
dest["receivedTimestamp"] = QDateTime::fromMSecsSinceEpoch(callLog->getData<time_t>("receivedTime") * 1000);
|
||||
dest["receivedTimestamp"] = QDateTime::fromMSecsSinceEpoch(callLog->getData<time_t>("receivedTime"));
|
||||
else
|
||||
dest["receivedTimestamp"] = dest["timestamp"];
|
||||
dest["isOutgoing"] = callLog->getDir() == linphone::Call::Dir::Outgoing;
|
||||
|
|
@ -64,7 +64,7 @@ static inline void fillCallEndEntry (QVariantMap &dest, const shared_ptr<linphon
|
|||
dest["type"] = HistoryModel::CallEntry;
|
||||
dest["timestamp"] = QDateTime::fromMSecsSinceEpoch((callLog->getStartDate() + callLog->getDuration()) * 1000);
|
||||
if(callLog->dataExists("receivedTime"))
|
||||
dest["receivedTimestamp"] = QDateTime::fromMSecsSinceEpoch((callLog->getData<time_t>("receivedTime") + callLog->getDuration()) * 1000);
|
||||
dest["receivedTimestamp"] = QDateTime::fromMSecsSinceEpoch(callLog->getData<time_t>("receivedTime") + (callLog->getDuration() * 1000));
|
||||
else
|
||||
dest["receivedTimestamp"] = dest["timestamp"];
|
||||
dest["isOutgoing"] = callLog->getDir() == linphone::Call::Dir::Outgoing;
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ function initView () {
|
|||
}
|
||||
|
||||
function getComponentFromEntry (chatEntry) {
|
||||
|
||||
if(!chatEntry) return ''
|
||||
if (chatEntry.type === Linphone.ChatRoomModel.CallEntry) {
|
||||
return 'Event.qml'
|
||||
}
|
||||
|
|
|
|||
|
|
@ -123,12 +123,12 @@ Rectangle {
|
|||
|
||||
delegate: Rectangle {
|
||||
id: entry
|
||||
property bool isNotice : $chatEntry.type === ChatRoomModel.NoticeEntry
|
||||
property bool isCall : $chatEntry.type === ChatRoomModel.CallEntry
|
||||
property bool isMessage : $chatEntry.type === ChatRoomModel.MessageEntry
|
||||
property bool isNotice : $chatEntry && ($chatEntry.type === ChatRoomModel.NoticeEntry)
|
||||
property bool isCall : $chatEntry && ($chatEntry.type === ChatRoomModel.CallEntry)
|
||||
property bool isMessage : $chatEntry && ($chatEntry.type === ChatRoomModel.MessageEntry)
|
||||
property var previousItem : proxyModel.count > 0 && index >0 ? proxyModel.getAt(index-1) : null
|
||||
property var nextItem : proxyModel.count > 0 ? proxyModel.getAt(index+1) : null // bind to count
|
||||
property bool displayDate: !Utils.equalDate(new Date($chatEntry.timestamp), new Date())
|
||||
property bool displayDate: $chatEntry && !Utils.equalDate(new Date($chatEntry.timestamp), new Date())
|
||||
property bool isTopGrouped: isGrouped(entry.previousItem, $chatEntry) || false
|
||||
property bool isBottomGrouped: isGrouped($chatEntry, entry.nextItem) || false
|
||||
|
||||
|
|
@ -177,7 +177,7 @@ Rectangle {
|
|||
RowLayout{
|
||||
id: headerLayout
|
||||
Layout.fillWidth: true
|
||||
Layout.alignment: Qt.AlignTop | ($chatEntry.isOutgoing ? Qt.AlignRight : Qt.AlignLeft)
|
||||
Layout.alignment: Qt.AlignTop | ($chatEntry && $chatEntry.isOutgoing ? Qt.AlignRight : Qt.AlignLeft)
|
||||
Layout.leftMargin: ChatStyle.entry.metaWidth// + ChatStyle.entry.message.extraContent.spacing
|
||||
Layout.rightMargin: ChatStyle.entry.message.outgoing.areaSize
|
||||
spacing:0
|
||||
|
|
@ -185,7 +185,7 @@ Rectangle {
|
|||
visible: !entry.isTopGrouped
|
||||
Text {
|
||||
id:timeDisplay
|
||||
Layout.alignment: Qt.AlignTop | ($chatEntry.isOutgoing ? Qt.AlignRight : Qt.AlignLeft)
|
||||
Layout.alignment: Qt.AlignTop | ($chatEntry && $chatEntry.isOutgoing ? Qt.AlignRight : Qt.AlignLeft)
|
||||
Layout.preferredHeight: implicitHeight// ChatStyle.entry.lineHeight
|
||||
//Layout.preferredWidth: ChatStyle.entry.time.width
|
||||
|
||||
|
|
@ -200,14 +200,14 @@ Rectangle {
|
|||
verticalAlignment: Text.AlignVCenter
|
||||
|
||||
TooltipArea {
|
||||
text: UtilsCpp.toDateTimeString($chatEntry.timestamp)
|
||||
text: $chatEntry ? UtilsCpp.toDateTimeString($chatEntry.timestamp) : ''
|
||||
}
|
||||
visible:!isNotice
|
||||
}
|
||||
Text{
|
||||
id:authorName
|
||||
//Layout.leftMargin: timeDisplay.width + ChatStyle.entry.metaWidth + ChatStyle.entry.message.extraContent.spacing
|
||||
property var displayName: $chatEntry.fromDisplayName ? $chatEntry.fromDisplayName : $chatEntry.name
|
||||
property var displayName: $chatEntry ? $chatEntry.fromDisplayName ? $chatEntry.fromDisplayName : $chatEntry.name : ''
|
||||
text : displayName != undefined ? displayName : ''
|
||||
|
||||
color: ChatStyle.entry.event.text.colorModel.color
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue