Commit e1ab4b5a authored by LNJ's avatar LNJ 🖖

Fix message counters and chat name

parent ba565584
......@@ -86,6 +86,13 @@ RosterManager::RosterManager(Kaidan *kaidan,
manager.refuseSubscription(jid);
});
// update local copy of chat partner
connect(kaidan->getMessageModel(), &MessageModel::chatPartnerChanged,
this, [=] (const QString &jid) {
m_chatPartner = jid;
}
);
// user actions
connect(kaidan, &Kaidan::addContact, this, &RosterManager::addContact);
connect(kaidan, &Kaidan::removeContact, this, &RosterManager::removeContact);
......
......@@ -39,7 +39,6 @@ import "elements"
Kirigami.ScrollablePage {
property string chatName
property string recipientJid
property bool isWritingSpoiler
property string messageToCorrect
......@@ -62,7 +61,7 @@ Kirigami.ScrollablePage {
id: fileChooser
title: qsTr("Select a file")
onAccepted: {
sendMediaSheet.jid = recipientJid
sendMediaSheet.jid = kaidan.messageModel.chatPartner
sendMediaSheet.fileUrl = fileUrl
sendMediaSheet.open()
}
......@@ -333,11 +332,18 @@ Kirigami.ScrollablePage {
// send the message
if (messageField.state == "compose") {
kaidan.sendMessage(recipientJid, messageField.text,
isWritingSpoiler, spoilerHintField.text)
kaidan.sendMessage(
kaidan.messageModel.chatPartner,
messageField.text,
isWritingSpoiler,
spoilerHintField.text
)
} else if (messageField.state == "edit") {
kaidan.correctMessage(recipientJid, messageToCorrect,
messageField.text)
kaidan.correctMessage(
kaidan.messageModel.chatPartner,
messageToCorrect,
messageField.text
)
}
// clean up the text fields
......
......@@ -75,17 +75,22 @@ Kirigami.ScrollablePage {
unreadMessages: model.unreadMessages
avatarImagePath: kaidan.avatarStorage.getAvatarUrl(model.jid)
backgroundColor: {
if (!Kirigami.Settings.isMobile && kaidan.chatPartner === model.jid) {
if (!Kirigami.Settings.isMobile &&
kaidan.messageModel.chatPartner === model.jid) {
Kirigami.Theme.highlightColor
} else {
Kirigami.Theme.backgroundColor
}
}
onClicked: {
// We need to cache the chatName, because changing the chatPartner in the
// message model will in some cases also update the roster model. That
// will then remove this item and readd an updated version of it, so
// model.* won't work anymore after this.
var chatName = model.name ? model.name : model.jid
kaidan.messageModel.chatPartner = model.jid
pageStack.push(chatPage, {
"chatName": (model.name ? model.name : model.jid),
"recipientJid": model.jid
"chatName": chatName
})
}
actions: [
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment