Display state of last message if it was sent by the user, fixes #152
This commit is contained in:
parent
7d78a2f126
commit
fcf1bb2118
2 changed files with 33 additions and 1 deletions
|
@ -19,7 +19,7 @@ PhotoTextsListItem {
|
||||||
// last message
|
// last message
|
||||||
secondaryText.text: last_message_text ? Emoji.emojify(last_message_text, Theme.fontSizeExtraSmall, emojiBase) : qsTr("Unknown")
|
secondaryText.text: last_message_text ? Emoji.emojify(last_message_text, Theme.fontSizeExtraSmall, emojiBase) : qsTr("Unknown")
|
||||||
// message date
|
// message date
|
||||||
tertiaryText.text: last_message_date ? Functions.getDateTimeElapsed(last_message_date) : qsTr("Unknown")
|
tertiaryText.text: ( last_message_date ? Functions.getDateTimeElapsed(last_message_date) : qsTr("Unknown") ) + Emoji.emojify(last_message_status, tertiaryText.font.pixelSize)
|
||||||
unreadCount: unread_count
|
unreadCount: unread_count
|
||||||
|
|
||||||
openMenuOnPressAndHold: true//chat_id != overviewPage.ownUserId
|
openMenuOnPressAndHold: true//chat_id != overviewPage.ownUserId
|
||||||
|
|
|
@ -42,6 +42,7 @@ namespace {
|
||||||
const QString NOTIFICATION_SETTINGS("notification_settings");
|
const QString NOTIFICATION_SETTINGS("notification_settings");
|
||||||
const QString LAST_READ_INBOX_MESSAGE_ID("last_read_inbox_message_id");
|
const QString LAST_READ_INBOX_MESSAGE_ID("last_read_inbox_message_id");
|
||||||
const QString LAST_READ_OUTBOX_MESSAGE_ID("last_read_outbox_message_id");
|
const QString LAST_READ_OUTBOX_MESSAGE_ID("last_read_outbox_message_id");
|
||||||
|
const QString SENDING_STATE("sending_state");
|
||||||
const QString IS_CHANNEL("is_channel");
|
const QString IS_CHANNEL("is_channel");
|
||||||
const QString _TYPE("@type");
|
const QString _TYPE("@type");
|
||||||
}
|
}
|
||||||
|
@ -60,6 +61,7 @@ public:
|
||||||
RoleLastMessageSenderId,
|
RoleLastMessageSenderId,
|
||||||
RoleLastMessageDate,
|
RoleLastMessageDate,
|
||||||
RoleLastMessageText,
|
RoleLastMessageText,
|
||||||
|
RoleLastMessageStatus,
|
||||||
RoleChatMemberStatus,
|
RoleChatMemberStatus,
|
||||||
RoleIsChannel
|
RoleIsChannel
|
||||||
};
|
};
|
||||||
|
@ -76,6 +78,7 @@ public:
|
||||||
qlonglong senderUserId() const;
|
qlonglong senderUserId() const;
|
||||||
qlonglong senderMessageDate() const;
|
qlonglong senderMessageDate() const;
|
||||||
QString senderMessageText() const;
|
QString senderMessageText() const;
|
||||||
|
QString senderMessageStatus() const;
|
||||||
bool isChannel() const;
|
bool isChannel() const;
|
||||||
bool isHidden() const;
|
bool isHidden() const;
|
||||||
bool updateUnreadCount(int unreadCount);
|
bool updateUnreadCount(int unreadCount);
|
||||||
|
@ -176,6 +179,28 @@ QString ChatListModel::ChatData::senderMessageText() const
|
||||||
return FernschreiberUtils::getMessageShortText(lastMessage(CONTENT).toMap(), this->userInformation.value(ID).toLongLong() == senderUserId());
|
return FernschreiberUtils::getMessageShortText(lastMessage(CONTENT).toMap(), this->userInformation.value(ID).toLongLong() == senderUserId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString ChatListModel::ChatData::senderMessageStatus() const
|
||||||
|
{
|
||||||
|
if (isChannel() || this->userInformation.value(ID).toLongLong() != senderUserId() || this->userInformation.value(ID).toLongLong() == chatId) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
if (lastMessage(ID) == chatData.value(LAST_READ_OUTBOX_MESSAGE_ID)) {
|
||||||
|
return " ✅";
|
||||||
|
} else {
|
||||||
|
QVariantMap lastMessage = chatData.value(LAST_MESSAGE).toMap();
|
||||||
|
if (lastMessage.contains(SENDING_STATE)) {
|
||||||
|
QVariantMap sendingState = lastMessage.value(SENDING_STATE).toMap();
|
||||||
|
if (sendingState.value(_TYPE).toString() == "messageSendingStatePending") {
|
||||||
|
return " 🕙";
|
||||||
|
} else {
|
||||||
|
return " ❌";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return " ☑️";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool ChatListModel::ChatData::isChannel() const
|
bool ChatListModel::ChatData::isChannel() const
|
||||||
{
|
{
|
||||||
return chatData.value(TYPE).toMap().value(IS_CHANNEL).toBool();
|
return chatData.value(TYPE).toMap().value(IS_CHANNEL).toBool();
|
||||||
|
@ -226,6 +251,8 @@ QVector<int> ChatListModel::ChatData::updateLastMessage(const QVariantMap &messa
|
||||||
const qlonglong prevSenderUserId(senderUserId());
|
const qlonglong prevSenderUserId(senderUserId());
|
||||||
const qlonglong prevSenderMessageDate(senderMessageDate());
|
const qlonglong prevSenderMessageDate(senderMessageDate());
|
||||||
const QString prevSenderMessageText(senderMessageText());
|
const QString prevSenderMessageText(senderMessageText());
|
||||||
|
const QString prevSenderMessageStatus(senderMessageStatus());
|
||||||
|
|
||||||
|
|
||||||
chatData.insert(LAST_MESSAGE, message);
|
chatData.insert(LAST_MESSAGE, message);
|
||||||
|
|
||||||
|
@ -240,6 +267,9 @@ QVector<int> ChatListModel::ChatData::updateLastMessage(const QVariantMap &messa
|
||||||
if (prevSenderMessageText != senderMessageText()) {
|
if (prevSenderMessageText != senderMessageText()) {
|
||||||
changedRoles.append(RoleLastMessageText);
|
changedRoles.append(RoleLastMessageText);
|
||||||
}
|
}
|
||||||
|
if (prevSenderMessageStatus != senderMessageStatus()) {
|
||||||
|
changedRoles.append(RoleLastMessageStatus);
|
||||||
|
}
|
||||||
return changedRoles;
|
return changedRoles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -297,6 +327,7 @@ QHash<int,QByteArray> ChatListModel::roleNames() const
|
||||||
roles.insert(ChatData::RoleLastMessageSenderId, "last_message_sender_id");
|
roles.insert(ChatData::RoleLastMessageSenderId, "last_message_sender_id");
|
||||||
roles.insert(ChatData::RoleLastMessageDate, "last_message_date");
|
roles.insert(ChatData::RoleLastMessageDate, "last_message_date");
|
||||||
roles.insert(ChatData::RoleLastMessageText, "last_message_text");
|
roles.insert(ChatData::RoleLastMessageText, "last_message_text");
|
||||||
|
roles.insert(ChatData::RoleLastMessageStatus, "last_message_status");
|
||||||
roles.insert(ChatData::RoleChatMemberStatus, "chat_member_status");
|
roles.insert(ChatData::RoleChatMemberStatus, "chat_member_status");
|
||||||
roles.insert(ChatData::RoleIsChannel, "is_channel");
|
roles.insert(ChatData::RoleIsChannel, "is_channel");
|
||||||
return roles;
|
return roles;
|
||||||
|
@ -323,6 +354,7 @@ QVariant ChatListModel::data(const QModelIndex &index, int role) const
|
||||||
case ChatData::RoleLastMessageSenderId: return data->senderUserId();
|
case ChatData::RoleLastMessageSenderId: return data->senderUserId();
|
||||||
case ChatData::RoleLastMessageText: return data->senderMessageText();
|
case ChatData::RoleLastMessageText: return data->senderMessageText();
|
||||||
case ChatData::RoleLastMessageDate: return data->senderMessageDate();
|
case ChatData::RoleLastMessageDate: return data->senderMessageDate();
|
||||||
|
case ChatData::RoleLastMessageStatus: return data->senderMessageStatus();
|
||||||
case ChatData::RoleChatMemberStatus: return data->memberStatus;
|
case ChatData::RoleChatMemberStatus: return data->memberStatus;
|
||||||
case ChatData::RoleIsChannel: return data->isChannel();
|
case ChatData::RoleIsChannel: return data->isChannel();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue