2020-12-17 10:40:37 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 2.13
|
|
|
|
import QtGraphicalEffects 1.13
|
|
|
|
import QtQml.Models 2.13
|
|
|
|
import QtQuick.Layouts 1.13
|
2021-09-28 15:04:06 +00:00
|
|
|
|
|
|
|
import utils 1.0
|
2021-10-27 21:27:49 +00:00
|
|
|
import shared 1.0
|
2021-10-28 20:23:30 +00:00
|
|
|
import shared.views 1.0
|
2021-10-27 21:27:49 +00:00
|
|
|
import shared.status 1.0
|
2021-10-28 20:23:30 +00:00
|
|
|
import shared.popups 1.0
|
2021-10-27 21:27:49 +00:00
|
|
|
import shared.controls 1.0
|
2021-10-28 20:23:30 +00:00
|
|
|
import shared.views.chat 1.0
|
2021-10-01 15:58:36 +00:00
|
|
|
|
|
|
|
import "../Chat/stores"
|
2021-10-28 20:23:30 +00:00
|
|
|
import "../Chat/popups"
|
2020-12-17 10:40:37 +00:00
|
|
|
|
2021-10-06 09:49:17 +00:00
|
|
|
import "stores"
|
|
|
|
import "panels"
|
|
|
|
|
2020-12-17 10:40:37 +00:00
|
|
|
ScrollView {
|
|
|
|
id: root
|
2021-10-06 09:49:17 +00:00
|
|
|
|
|
|
|
property RootStore store: RootStore { }
|
2021-12-09 16:25:38 +00:00
|
|
|
property var chatSectionModule
|
2021-10-06 09:49:17 +00:00
|
|
|
|
2020-12-17 10:40:37 +00:00
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
2021-01-22 19:21:26 +00:00
|
|
|
contentHeight: chatLogView.contentHeight + 140
|
2020-12-17 10:40:37 +00:00
|
|
|
clip: true
|
|
|
|
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
|
2021-01-22 19:21:26 +00:00
|
|
|
|
2021-10-01 15:58:36 +00:00
|
|
|
property var rootStore
|
|
|
|
property var messageStore
|
2020-12-17 10:40:37 +00:00
|
|
|
property var onActivated: function () {
|
2021-10-06 09:49:17 +00:00
|
|
|
store.setActiveChannelToTimeline()
|
2020-12-17 10:40:37 +00:00
|
|
|
statusUpdateInput.textInput.forceActiveFocus(Qt.MouseFocusReason)
|
|
|
|
}
|
|
|
|
|
|
|
|
Component.onCompleted: {
|
|
|
|
statusUpdateInput.textInput.forceActiveFocus(Qt.MouseFocusReason)
|
|
|
|
}
|
|
|
|
|
|
|
|
function openProfilePopup(userNameParam, fromAuthorParam, identiconParam, textParam, nicknameParam, parentPopup){
|
2021-12-31 12:29:51 +00:00
|
|
|
Global.openProfilePopup(fromAuthorParam)
|
2020-12-17 10:40:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
StatusImageModal {
|
|
|
|
id: imagePopup
|
2021-08-16 09:11:43 +00:00
|
|
|
onClicked: {
|
2021-08-25 20:31:00 +00:00
|
|
|
close()
|
2021-08-16 09:11:43 +00:00
|
|
|
}
|
2020-12-17 10:40:37 +00:00
|
|
|
}
|
|
|
|
|
2021-01-14 20:09:07 +00:00
|
|
|
Item {
|
2020-12-17 10:40:37 +00:00
|
|
|
id: timelineContainer
|
|
|
|
width: 624
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
2021-01-14 20:09:07 +00:00
|
|
|
anchors.bottom: parent.bottom
|
2020-12-17 10:40:37 +00:00
|
|
|
|
2021-10-06 09:49:17 +00:00
|
|
|
// TODO: Replace this with StatusQ component once it lives there.
|
2020-12-17 10:40:37 +00:00
|
|
|
StatusChatInput {
|
|
|
|
id: statusUpdateInput
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.topMargin: 40
|
2021-12-09 12:53:40 +00:00
|
|
|
chatType: Constants.chatType.profile
|
2021-03-10 04:59:01 +00:00
|
|
|
imageErrorMessageLocation: StatusChatInput.ImageErrorMessageLocation.Bottom
|
|
|
|
z: 1
|
2020-12-17 10:40:37 +00:00
|
|
|
onSendMessage: {
|
|
|
|
if (statusUpdateInput.fileUrls.length > 0){
|
2021-03-10 04:59:01 +00:00
|
|
|
statusUpdateInput.fileUrls.forEach(url => {
|
2021-10-06 09:49:17 +00:00
|
|
|
root.store.sendImage(url);
|
2021-03-10 04:59:01 +00:00
|
|
|
})
|
2020-12-17 10:40:37 +00:00
|
|
|
}
|
2021-10-06 09:49:17 +00:00
|
|
|
var msg = root.store.getPlainTextFromRichText(Emoji.deparse(statusUpdateInput.textInput.text))
|
2020-12-17 10:40:37 +00:00
|
|
|
if (msg.length > 0){
|
|
|
|
msg = statusUpdateInput.interpretMessage(msg)
|
2021-12-09 12:53:40 +00:00
|
|
|
root.store.sendMessage(msg, Utils.isOnlyEmoji(msg) ? Constants.messageContentType.emojiType : Constants.messageContentType.messageType);
|
2020-12-17 10:40:37 +00:00
|
|
|
statusUpdateInput.textInput.text = "";
|
|
|
|
if(event) event.accepted = true
|
2021-03-30 14:52:23 +00:00
|
|
|
sendMessageSound.stop()
|
|
|
|
Qt.callLater(sendMessageSound.play);
|
2020-12-17 10:40:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-06 09:49:17 +00:00
|
|
|
EmptyTimelinePanel {
|
2020-12-17 10:40:37 +00:00
|
|
|
id: emptyTimeline
|
|
|
|
anchors.top: statusUpdateInput.bottom
|
|
|
|
anchors.topMargin: 40
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
2021-07-15 14:20:17 +00:00
|
|
|
visible: chatLogView.count === 0
|
2020-12-17 10:40:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ListView {
|
|
|
|
id: chatLogView
|
|
|
|
anchors.top: statusUpdateInput.bottom
|
2021-01-14 20:09:07 +00:00
|
|
|
anchors.topMargin: Style.current.bigPadding
|
2020-12-17 10:40:37 +00:00
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
2021-01-14 20:09:07 +00:00
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
spacing: Style.current.halfPadding
|
2020-12-17 10:40:37 +00:00
|
|
|
flickDeceleration: 10000
|
|
|
|
interactive: false
|
|
|
|
|
2021-06-22 18:30:51 +00:00
|
|
|
model: messageListDelegate
|
2020-12-17 10:40:37 +00:00
|
|
|
section.property: "sectionIdentifier"
|
|
|
|
section.criteria: ViewSection.FullString
|
2021-07-13 07:34:13 +00:00
|
|
|
|
2021-12-13 14:24:21 +00:00
|
|
|
// Not Refactored Yet
|
|
|
|
// Connections {
|
|
|
|
// target: root.store.chatsModelInst.messageView
|
|
|
|
// onMessagesLoaded: {
|
|
|
|
// Qt.callLater(chatLogView.positionViewAtBeginning)
|
|
|
|
// }
|
|
|
|
// }
|
2021-06-22 18:30:51 +00:00
|
|
|
}
|
|
|
|
|
2021-07-15 14:59:30 +00:00
|
|
|
Timer {
|
|
|
|
id: ageUpdateTimer
|
|
|
|
property int epoch: 0
|
|
|
|
running: true
|
|
|
|
repeat: true
|
|
|
|
interval: 60000 // 1 min
|
|
|
|
onTriggered: epoch = epoch + 1
|
|
|
|
}
|
|
|
|
|
2021-06-22 18:30:51 +00:00
|
|
|
DelegateModelGeneralized {
|
|
|
|
id: messageListDelegate
|
|
|
|
lessThan: [
|
|
|
|
function(left, right) { return left.clock > right.clock }
|
|
|
|
]
|
2021-12-13 14:24:21 +00:00
|
|
|
// Not Refactored Yet
|
|
|
|
// model: root.store.chatsModelInst.messageView.messageList
|
2021-10-06 09:49:17 +00:00
|
|
|
// TODO: Replace with StatusQ component once it lives there.
|
2021-10-01 15:58:36 +00:00
|
|
|
delegate: MessageView {
|
2020-12-17 10:40:37 +00:00
|
|
|
id: msgDelegate
|
2021-12-09 12:53:40 +00:00
|
|
|
// Not Refactored Yet
|
|
|
|
|
|
|
|
// rootStore: root.rootStore
|
|
|
|
// messageStore: root.messageStore
|
|
|
|
// fromAuthor: model.fromAuthor
|
|
|
|
// chatId: model.chatId
|
|
|
|
// userName: model.userName
|
|
|
|
// alias: model.alias
|
|
|
|
// localName: model.localName
|
|
|
|
// message: model.message
|
|
|
|
// plainText: model.plainText
|
|
|
|
// identicon: model.identicon
|
|
|
|
// isCurrentUser: model.isCurrentUser
|
|
|
|
// timestamp: model.timestamp
|
|
|
|
// sticker: model.sticker
|
|
|
|
// contentType: model.contentType
|
|
|
|
// outgoingStatus: model.outgoingStatus
|
|
|
|
// responseTo: model.responseTo
|
|
|
|
// authorCurrentMsg: msgDelegate.ListView.section
|
|
|
|
// authorPrevMsg: msgDelegate.ListView.previousSection
|
|
|
|
// imageClick: imagePopup.openPopup.bind(imagePopup)
|
|
|
|
// messageId: model.messageId
|
|
|
|
// emojiReactions: model.emojiReactions
|
|
|
|
// isStatusUpdate: true
|
|
|
|
// statusAgeEpoch: ageUpdateTimer.epoch
|
|
|
|
// // This is used in order to have access to the previous message and determine the timestamp
|
|
|
|
// // we can't rely on the index because the sequence of messages is not ordered on the nim side
|
|
|
|
// prevMessageIndex: {
|
|
|
|
// // This is used in order to have access to the previous message and determine the timestamp
|
|
|
|
// // we can't rely on the index because the sequence of messages is not ordered on the nim side
|
|
|
|
// if(msgDelegate.DelegateModel.itemsIndex > 0){
|
|
|
|
// return messageListDelegate.items.get(msgDelegate.DelegateModel.itemsIndex - 1).model.index
|
|
|
|
// }
|
|
|
|
// return -1;
|
|
|
|
// }
|
|
|
|
// timeout: model.timeout
|
|
|
|
// messageContextMenu: msgCntxtMenu
|
|
|
|
// Component.onCompleted: {
|
|
|
|
// messageStore.fromAuthor = model.fromAuthor;
|
|
|
|
// messageStore.chatId = model.chatId;
|
|
|
|
// messageStore.userName = model.userName;
|
|
|
|
// messageStore.alias = model.alias;
|
|
|
|
// messageStore.localName = model.localName;
|
|
|
|
// messageStore.message = model.message;
|
|
|
|
// messageStore.plainText = model.plainText;
|
|
|
|
// messageStore.identicon = model.identicon;
|
|
|
|
// messageStore.isCurrentUser = model.isCurrentUser;
|
|
|
|
// messageStore.timestamp = model.timestamp;
|
|
|
|
// messageStore.sticker = model.sticker;
|
|
|
|
// messageStore.contentType = model.contentType;
|
|
|
|
// messageStore.outgoingStatus = model.outgoingStatus;
|
|
|
|
// messageStore.responseTo = model.responseTo;
|
|
|
|
// messageStore.authorCurrentMsg = msgDelegate.ListView.section;
|
|
|
|
// messageStore.authorPrevMsg = msgDelegate.ListView.previousSection;
|
|
|
|
// messageStore.imageClick = imagePopup.openPopup.bind(imagePopup);
|
|
|
|
// messageStore.messageId = model.messageId;
|
|
|
|
// messageStore.emojiReactions = model.emojiReactions;
|
|
|
|
// messageStore.isStatusUpdate = true;
|
|
|
|
// messageStore.statusAgeEpoch = ageUpdateTimer.epoch;
|
|
|
|
// // This is used in order to have access to the previous message and determine the timestamp
|
|
|
|
// // we can't rely on the index because the sequence of messages is not ordered on the nim side
|
|
|
|
// messageStore.prevMessageIndex =
|
|
|
|
// // This is used in order to have access to the previous message and determine the timestamp
|
|
|
|
// // we can't rely on the index because the sequence of messages is not ordered on the nim side
|
|
|
|
// (msgDelegate.DelegateModel.itemsIndex > 0) ?
|
|
|
|
// messageListDelegate.items.get(msgDelegate.DelegateModel.itemsIndex - 1).model.index : -1;
|
|
|
|
// messageStore.timeout = model.timeout;
|
|
|
|
// messageStore.messageContextMenu = msgCntxtMenu;
|
|
|
|
// }
|
2021-12-14 14:19:55 +00:00
|
|
|
// MessageContextMenuView {
|
|
|
|
// id: msgCntxtMenu
|
|
|
|
// store: root.store
|
|
|
|
// chatSectionModule: root.chatSectionModule
|
|
|
|
// reactionModel: EmojiReactions { }
|
|
|
|
// }
|
2021-06-10 21:07:41 +00:00
|
|
|
}
|
|
|
|
}
|
2021-07-14 10:10:08 +00:00
|
|
|
|
|
|
|
Loader {
|
2021-10-06 09:49:17 +00:00
|
|
|
active: root.store.chatsModelInst.messageView.loadingMessages
|
|
|
|
// TODO: replace with StatusLoadingIndicator
|
2021-07-14 10:10:08 +00:00
|
|
|
sourceComponent: LoadingAnimation {}
|
|
|
|
anchors.right: timelineContainer.right
|
|
|
|
anchors.top: statusUpdateInput.bottom
|
|
|
|
anchors.rightMargin: Style.current.padding
|
|
|
|
anchors.topMargin: Style.current.padding
|
|
|
|
}
|
2020-12-17 10:40:37 +00:00
|
|
|
}
|
|
|
|
}
|