2020-10-31 22:49:03 +03:00
|
|
|
import QtQuick 2.6
|
2020-10-19 13:20:02 +03:00
|
|
|
import Sailfish.Silica 1.0
|
|
|
|
|
|
|
|
import "../js/twemoji.js" as Emoji
|
|
|
|
import "../js/functions.js" as Functions
|
|
|
|
|
|
|
|
PhotoTextsListItem {
|
|
|
|
id: listItem
|
|
|
|
pictureThumbnail {
|
|
|
|
photoData: photo_small
|
|
|
|
}
|
|
|
|
property int ownUserId
|
2020-11-03 01:19:50 +03:00
|
|
|
property url emojiBase: "../js/emoji/"
|
2020-10-19 13:20:02 +03:00
|
|
|
|
|
|
|
// chat title
|
2020-11-07 22:58:23 +03:00
|
|
|
primaryText.text: title ? Emoji.emojify(title + ( display.notification_settings.mute_for > 0 ? " 🔇" : "" ), Theme.fontSizeMedium, emojiBase) : qsTr("Unknown")
|
2020-10-19 13:20:02 +03:00
|
|
|
// last user
|
|
|
|
prologSecondaryText.text: is_channel ? "" : ( last_message_sender_id ? ( last_message_sender_id !== ownUserId ? Emoji.emojify(Functions.getUserName(tdLibWrapper.getUserInformation(last_message_sender_id)), primaryText.font.pixelSize) : qsTr("You") ) : qsTr("Unknown") )
|
|
|
|
// last message
|
2020-11-03 01:19:50 +03:00
|
|
|
secondaryText.text: last_message_text ? Emoji.emojify(last_message_text, Theme.fontSizeExtraSmall, emojiBase) : qsTr("Unknown")
|
2020-10-19 13:20:02 +03:00
|
|
|
// message date
|
|
|
|
tertiaryText.text: last_message_date ? Functions.getDateTimeElapsed(last_message_date) : qsTr("Unknown")
|
|
|
|
unreadCount: unread_count
|
|
|
|
|
|
|
|
openMenuOnPressAndHold: true//chat_id != overviewPage.ownUserId
|
|
|
|
menu: ContextMenu {
|
2020-10-19 16:30:03 +03:00
|
|
|
MenuItem {
|
|
|
|
visible: unread_count > 0
|
|
|
|
onClicked: {
|
|
|
|
tdLibWrapper.viewMessage(chat_id, display.last_message.id, true);
|
|
|
|
}
|
|
|
|
text: qsTr("Mark all messages as read")
|
|
|
|
}
|
|
|
|
|
2020-10-19 13:20:02 +03:00
|
|
|
MenuItem {
|
|
|
|
visible: chat_id != listItem.ownUserId
|
|
|
|
onClicked: {
|
|
|
|
var newNotificationSettings = display.notification_settings;
|
|
|
|
if (newNotificationSettings.mute_for > 0) {
|
|
|
|
newNotificationSettings.mute_for = 0;
|
|
|
|
} else {
|
|
|
|
newNotificationSettings.mute_for = 6666666;
|
|
|
|
}
|
|
|
|
tdLibWrapper.setChatNotificationSettings(chat_id, newNotificationSettings);
|
|
|
|
}
|
|
|
|
text: display.notification_settings.mute_for > 0 ? qsTr("Unmute Chat") : qsTr("Mute Chat")
|
|
|
|
}
|
|
|
|
|
|
|
|
MenuItem {
|
|
|
|
onClicked: {
|
|
|
|
if(pageStack.depth > 2) {
|
|
|
|
pageStack.pop(pageStack.find( function(page){ return(page._depth === 0)} ), PageStackAction.Immediate);
|
|
|
|
}
|
|
|
|
|
|
|
|
pageStack.push(Qt.resolvedUrl("../pages/ChatInformationPage.qml"), { "chatInformation" : display});
|
|
|
|
}
|
|
|
|
text: model.display.type['@type'] === "chatTypePrivate" ? qsTr("User Info") : qsTr("Group Info")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|