refactor(desktop/chat) Cleaning up views

This commit is contained in:
Alexandra Betouni 2021-10-22 01:39:53 +03:00 committed by Iuri Matias
parent 22429689e3
commit 23811dc7e4
21 changed files with 372 additions and 369 deletions

View File

@ -20,48 +20,48 @@ import StatusQ.Layout 0.1
import StatusQ.Popups 0.1
StatusAppThreePanelLayout {
id: chatView
id: root
handle: SplitViewHandle { implicitWidth: 5 }
property var messageStore
property RootStore rootStore: RootStore {
messageStore: chatView.messageStore
messageStore: root.messageStore
}
property alias chatColumn: chatColumn
property bool stickersLoaded: false
signal profileButtonClicked()
Connections {
target: chatsModel.stickers
target: root.rootStore.chatsModelInst.stickers
onStickerPacksLoaded: {
stickersLoaded = true;
}
}
property var onActivated: function () {
chatsModel.channelView.restorePreviousActiveChannel()
chatColumn.onActivated()
root.rootStore.chatsModelInst.channelView.restorePreviousActiveChannel();
chatColumn.onActivated();
}
StatusSearchLocationMenu {
id: searchPopupMenu
searchPopup: searchPopup
locationModel: chatsModel.messageSearchViewController.locationMenuModel
locationModel: root.rootStore.chatsModelInst.messageSearchViewController.locationMenuModel
onItemClicked: {
chatsModel.messageSearchViewController.setSearchLocation(firstLevelItemValue, secondLevelItemValue)
root.rootStore.chatsModelInst.messageSearchViewController.setSearchLocation(firstLevelItemValue, secondLevelItemValue)
if(searchPopup.searchText !== "")
searchMessages(searchPopup.searchText)
}
}
property var searchMessages: Backpressure.debounce(searchPopup, 400, function (value) {
chatsModel.messageSearchViewController.searchMessages(value)
root.rootStore.chatsModelInst.messageSearchViewController.searchMessages(value)
})
Connections {
target: chatsModel.messageSearchViewController.locationMenuModel
target: root.rootStore.chatsModelInst.messageSearchViewController.locationMenuModel
onModelAboutToBeReset: {
for (var i = 2; i <= searchPopupMenu.count; i++) {
//clear menu
@ -79,7 +79,7 @@ StatusAppThreePanelLayout {
defaultSearchLocationText: qsTr("Anywhere")
searchOptionsPopupMenu: searchPopupMenu
searchResults: chatsModel.messageSearchViewController.resultModel
searchResults: root.rootStore.chatsModelInst.messageSearchViewController.resultModel
formatTimestampFn: function (ts) {
return new Date(parseInt(ts, 10)).toLocaleString(Qt.locale(globalSettings.locale))
@ -99,9 +99,9 @@ StatusAppThreePanelLayout {
onOpened: {
searchPopup.resetSearchSelection();
searchPopup.forceActiveFocus()
chatsModel.messageSearchViewController.prepareLocationMenuModel()
root.rootStore.chatsModelInst.messageSearchViewController.prepareLocationMenuModel()
const jsonObj = chatsModel.messageSearchViewController.getSearchLocationObject()
const jsonObj = root.rootStore.chatsModelInst.messageSearchViewController.getSearchLocationObject()
if (!jsonObj) {
return
@ -110,7 +110,7 @@ StatusAppThreePanelLayout {
let obj = JSON.parse(jsonObj)
if (obj.location === "") {
if(obj.subLocation === "") {
chatsModel.messageSearchViewController.setSearchLocation("", "")
root.rootStore.chatsModelInst.messageSearchViewController.setSearchLocation("", "")
}
else {
searchPopup.setSearchSelection(obj.subLocation.text,
@ -120,7 +120,7 @@ StatusAppThreePanelLayout {
obj.subLocation.iconName,
obj.subLocation.identiconColor)
chatsModel.messageSearchViewController.setSearchLocation("", obj.subLocation.value)
root.rootStore.chatsModelInst.messageSearchViewController.setSearchLocation("", obj.subLocation.value)
}
}
else {
@ -132,7 +132,7 @@ StatusAppThreePanelLayout {
obj.subLocation.iconName,
obj.subLocation.identiconColor)
chatsModel.messageSearchViewController.setSearchLocation(obj.location.value, obj.subLocation.value)
root.rootStore.chatsModelInst.messageSearchViewController.setSearchLocation(obj.location.value, obj.subLocation.value)
}
else {
searchPopup.setSearchSelection(obj.location.title,
@ -142,46 +142,46 @@ StatusAppThreePanelLayout {
obj.location.iconName,
obj.location.identiconColor)
chatsModel.messageSearchViewController.setSearchLocation(obj.location.value, obj.subLocation.value)
root.rootStore.chatsModelInst.messageSearchViewController.setSearchLocation(obj.location.value, obj.subLocation.value)
}
}
}
onResultItemClicked: {
searchPopup.close()
chatsModel.switchToSearchedItem(itemId)
root.rootStore.chatsModelInst.switchToSearchedItem(itemId)
}
onResultItemTitleClicked: {
const pk = titleId
const userProfileImage = appMain.getProfileImage(pk)
return openProfilePopup(chatsModel.userNameOrAlias(pk), pk, userProfileImage || utilsModel.generateIdenticon(pk))
return openProfilePopup(root.rootStore.chatsModelInst.userNameOrAlias(pk), pk, userProfileImage || root.rootStore.utilsModelInst.generateIdenticon(pk))
}
}
leftPanel: Loader {
id: contactColumnLoader
sourceComponent: appSettings.communitiesEnabled && chatsModel.communities.activeCommunity.active ? communtiyColumnComponent : contactsColumnComponent
sourceComponent: appSettings.communitiesEnabled && root.rootStore.chatsModelInst.communities.activeCommunity.active ? communtiyColumnComponent : contactsColumnComponent
}
centerPanel: ChatColumnView {
id: chatColumn
rootStore: chatView.rootStore
rootStore: root.rootStore
chatGroupsListViewCount: contactColumnLoader.item.chatGroupsListViewCount
}
showRightPanel: (appSettings.expandUsersList && (appSettings.showOnlineUsers || chatsModel.communities.activeCommunity.active)
&& (chatsModel.channelView.activeChannel.chatType !== Constants.chatTypeOneToOne))
rightPanel: appSettings.communitiesEnabled && chatsModel.communities.activeCommunity.active ? communityUserListComponent : userListComponent
showRightPanel: (appSettings.expandUsersList && (appSettings.showOnlineUsers || root.rootStore.chatsModelInst.communities.activeCommunity.active)
&& (root.rootStore.chatsModelInst.channelView.activeChannel.chatType !== Constants.chatTypeOneToOne))
rightPanel: appSettings.communitiesEnabled && root.rootStore.chatsModelInst.communities.activeCommunity.active ? communityUserListComponent : userListComponent
Component {
id: communityUserListComponent
CommunityUserListPanel {
currentTime: chatColumn.currentTime
messageContextMenu: quickActionMessageOptionsMenu
profilePubKey: profileModel.profile.pubKey
contactsList: profileModel.contacts.list
community: chatsModel.communities.activeCommunity
profilePubKey: root.rootStore.profileModelInst.profile.pubKey
contactsList: root.rootStore.profileModelInst.contacts.list
community: root.rootStore.chatsModelInst.communities.activeCommunity
}
}
@ -191,17 +191,18 @@ StatusAppThreePanelLayout {
currentTime: chatColumn.currentTime
userList: chatColumn.userList
messageContextMenu: quickActionMessageOptionsMenu
profilePubKey: profileModel.profile.pubKey
contactsList: profileModel.contacts.list
isOnline: chatsModel.isOnline
profilePubKey: root.rootStore.profileModelInst.profile.pubKey
contactsList: root.rootStore.profileModelInst.contacts.list
isOnline: root.rootStore.chatsModelInst.isOnline
}
}
Component {
id: contactsColumnComponent
ContactsColumnView {
store: root.rootStore
onOpenProfileClicked: {
chatView.profileButtonClicked();
root.profileButtonClicked();
}
}
}
@ -209,7 +210,7 @@ StatusAppThreePanelLayout {
Component {
id: communtiyColumnComponent
CommunityColumnView {
rootStore: chatColumn.rootStore
store: root.rootStore
pinnedMessagesPopupComponent: chatColumn.pinnedMessagesPopupComponent
}
}
@ -237,8 +238,8 @@ StatusAppThreePanelLayout {
//% "Are you sure you want to remove this contact?"
confirmationText: qsTrId("are-you-sure-you-want-to-remove-this-contact-")
onConfirmButtonClicked: {
if (profileModel.contacts.isAdded(chatColumn.contactToRemove)) {
profileModel.contacts.removeContact(chatColumn.contactToRemove)
if (root.rootStore.profileModelInst.contacts.isAdded(chatColumn.contactToRemove)) {
root.rootStore.profileModelInst.contacts.removeContact(chatColumn.contactToRemove)
}
removeContactConfirmationDialog.parentPopup.close();
removeContactConfirmationDialog.close();
@ -247,8 +248,8 @@ StatusAppThreePanelLayout {
MessageContextMenuView {
id: quickActionMessageOptionsMenu
store: chatColumn.rootStore
reactionModel: chatColumn.rootStore.emojiReactionsModel
store: root.rootStore
reactionModel: root.rootStore.emojiReactionsModel
}
}

View File

@ -7,11 +7,10 @@ import utils 1.0
StyledText {
id: chatTime
//property string timestamp
visible: chatTime.messageStore.isMessage
color: Style.current.secondaryText
text: Utils.formatTime(timestamp)
font.pixelSize: Style.current.asideTextFontSize
//property string timestamp
StatusQ.StatusToolTip {
visible: hhandler.hovered

View File

@ -214,7 +214,7 @@ Popup {
id: groupRequestNotificationComponent
ActivityCenterGroupRequest {
timestamp: activityCenter.store.messageStore.timestamp
store: activityCenter.store
}
}
}

View File

@ -4,10 +4,12 @@ import utils 1.0
QtObject {
id: root
objectName: "hello!"
property var messageStore
property EmojiReactions emojiReactionsModel: EmojiReactions { }
property var chatsModelInst: chatsModel
property var utilsModelInst: utilsModel
property var walletModelInst: walletModel
property var profileModelInst: profileModel

View File

@ -13,6 +13,7 @@ Item {
width: parent.width
height: childrenRect.height
property var store
Separator {
id: separator1

View File

@ -17,7 +17,7 @@ Item {
id: root
width: parent.width
height: childrenRect.height + dateGroupLbl.anchors.topMargin
property string timestamp: ""
property var store
DateGroup {
id: dateGroupLbl
previousMessageIndex: previousNotificationIndex
@ -90,7 +90,7 @@ Item {
font.weight: Font.Medium
}
ChatTimeView {
ChatTimePanel {
anchors.verticalCenter: chatName.verticalCenter
anchors.left: chatName.right
anchors.leftMargin: 4
@ -104,7 +104,7 @@ Item {
function openProfile() {
const pk = model.author
const userProfileImage = appMain.getProfileImage(pk)
openProfilePopup(chatsModel.userNameOrAlias(pk), pk, userProfileImage || utilsModel.generateIdenticon(pk))
openProfilePopup(root.store.chatsModelInst.userNameOrAlias(pk), pk, userProfileImage || utilsModel.generateIdenticon(pk))
}
StyledTextEdit {
@ -115,7 +115,7 @@ Item {
return ""
}
let name = chatsModel.userNameOrAlias(model.author)
let name = root.store.chatsModelInst.userNameOrAlias(model.author)
if (name.length > 20) {
name = name.substring(0, 9) + "..." + name.substring(name.length - 10)
}
@ -152,12 +152,12 @@ Item {
anchors.right: parent.right
anchors.rightMargin: Style.current.halfPadding
anchors.verticalCenter: parent.verticalCenter
onAcceptClicked: chatsModel.activityNotificationList.acceptActivityCenterNotification(model.id)
onDeclineClicked: chatsModel.activityNotificationList.dismissActivityCenterNotification(model.id)
onAcceptClicked: root.store.chatsModelInst.activityNotificationList.acceptActivityCenterNotification(model.id)
onDeclineClicked: root.store.chatsModelInst.activityNotificationList.dismissActivityCenterNotification(model.id)
onProfileClicked: groupRequestContent.openProfile()
onBlockClicked: {
const pk = model.author
blockContactConfirmationDialog.contactName = chatsModel.userNameOrAlias(pk)
blockContactConfirmationDialog.contactName = root.store.chatsModelInst.userNameOrAlias(pk)
blockContactConfirmationDialog.contactAddress = pk
blockContactConfirmationDialog.open()
}
@ -165,8 +165,8 @@ Item {
BlockContactConfirmationDialog {
id: blockContactConfirmationDialog
onBlockButtonClicked: {
profileModel.contacts.blockContact(blockContactConfirmationDialog.contactAddress)
chatsModel.activityNotificationList.dismissActivityCenterNotification(model.id)
root.store.profileModelInst.contacts.blockContact(blockContactConfirmationDialog.contactAddress)
root.store.chatsModelInst.activityNotificationList.dismissActivityCenterNotification(model.id)
blockContactConfirmationDialog.close()
}
}

View File

@ -14,28 +14,26 @@ import "../popups"
Item {
id: root
property int communityIndex: chatsModel.communities.joinedCommunities.getCommunityIndex(model.message.communityId)
width: parent.width
// Setting a height of 0 breaks the layout for when it comes back visible
// The Item never goes back to actually have a height or width
height: visible ? messageNotificationContent.height : 0.01
visible: {
if (hideReadNotifications && model.read) {
return false
}
return activityCenter.currentFilter === ActivityCenterPopup.Filter.All ||
(model.notificationType === Constants.activityCenterNotificationTypeMention && activityCenter.currentFilter === ActivityCenterPopup.Filter.Mentions) ||
(model.notificationType === Constants.activityCenterNotificationTypeOneToOne && activityCenter.currentFilter === ActivityCenterPopup.Filter.ContactRequests) ||
(model.notificationType === Constants.activityCenterNotificationTypeReply && activityCenter.currentFilter === ActivityCenterPopup.Filter.Replies)
}
width: parent.width
// Setting a height of 0 breaks the layout for when it comes back visible
// The Item never goes back to actually have a height or width
height: visible ? messageNotificationContent.height : 0.01
property var store
property int communityIndex: root.store.chatsModelInst.communities.joinedCommunities.getCommunityIndex(model.message.communityId)
function openProfile() {
const pk = model.author
const userProfileImage = appMain.getProfileImage(pk)
openProfilePopup(chatsModel.userNameOrAlias(pk), pk, userProfileImage || utilsModel.generateIdenticon(pk))
openProfilePopup(root.store.chatsModelInst.userNameOrAlias(pk), pk, userProfileImage || utilsModel.generateIdenticon(pk))
}
Component {
@ -53,7 +51,7 @@ Item {
tooltip.orientation: StatusQ.StatusToolTip.Orientation.Left
tooltip.x: -tooltip.width - Style.current.padding
tooltip.y: markReadBtn.height / 2 - height / 2 + 4
onClicked: chatsModel.activityNotificationList.markActivityCenterNotificationRead(model.id, model.message.communityId, model.message.chatId, model.notificationType)
onClicked: root.store.chatsModelInst.activityNotificationList.markActivityCenterNotificationRead(model.id, model.message.communityId, model.message.chatId, model.notificationType)
}
}
@ -63,15 +61,15 @@ Item {
AcceptRejectOptionsButtonsPanel {
id: buttons
onAcceptClicked: {
const setActiveChannel = chatsModel.channelView.setActiveChannel
const setActiveChannel = root.store.chatsModelInst.channelView.setActiveChannel
const chatId = model.message.chatId
const messageId = model.message.messageId
profileModel.contacts.addContact(model.author)
chatsModel.activityNotificationList.acceptActivityCenterNotification(model.id)
root.store.profileModelInst.contacts.addContact(model.author)
root.store.chatsModelInst.activityNotificationList.acceptActivityCenterNotification(model.id)
setActiveChannel(chatId)
positionAtMessage(messageId)
}
onDeclineClicked: chatsModel.activityNotificationList.dismissActivityCenterNotification(model.id)
onDeclineClicked: root.store.chatsModelInst.activityNotificationList.dismissActivityCenterNotification(model.id)
onProfileClicked: root.openProfile()
onBlockClicked: {
const pk = model.author
@ -83,8 +81,8 @@ Item {
BlockContactConfirmationDialog {
id: blockContactConfirmationDialog
onBlockButtonClicked: {
profileModel.contacts.blockContact(blockContactConfirmationDialog.contactAddress)
chatsModel.activityNotificationList.dismissActivityCenterNotification(model.id)
root.store.profileModelInst.contacts.blockContact(blockContactConfirmationDialog.contactAddress)
root.store.chatsModelInst.activityNotificationList.dismissActivityCenterNotification(model.id)
blockContactConfirmationDialog.close()
}
}
@ -130,16 +128,16 @@ Item {
if (isProfileClick) {
const pk = model.message.fromAuthor
const userProfileImage = appMain.getProfileImage(pk)
return openProfilePopup(chatsModel.userNameOrAlias(pk), pk, userProfileImage || utilsModel.generateIdenticon(pk))
return openProfilePopup(root.store.chatsModelInst.userNameOrAlias(pk), pk, userProfileImage || root.store.utilsModelInst.generateIdenticon(pk))
}
activityCenter.close()
if (model.message.communityId) {
chatsModel.communities.setActiveCommunity(model.message.communityId)
root.store.chatsModelInst.communities.setActiveCommunity(model.message.communityId)
}
chatsModel.channelView.setActiveChannel(model.message.chatId)
root.store.chatsModelInst.channelView.setActiveChannel(model.message.chatId)
positionAtMessage(model.message.messageId)
}
@ -176,16 +174,16 @@ Item {
if (isProfileClick) {
const pk = model.message.fromAuthor
const userProfileImage = appMain.getProfileImage(pk)
return openProfilePopup(chatsModel.userNameOrAlias(pk), pk, userProfileImage || utilsModel.generateIdenticon(pk))
return openProfilePopup(root.store.chatsModelInst.userNameOrAlias(pk), pk, userProfileImage || root.store.utilsModelInst.generateIdenticon(pk))
}
activityCenter.close()
if (model.message.communityId) {
chatsModel.communities.setActiveCommunity(model.message.communityId)
root.store.chatsModelInst.communities.setActiveCommunity(model.message.communityId)
}
chatsModel.channelView.setActiveChannel(model.message.chatId)
root.store.chatsModelInst.channelView.setActiveChannel(model.message.chatId)
positionAtMessage(model.message.messageId)
}
}
@ -228,10 +226,10 @@ Item {
chatId: model.chatId
notificationType: model.notificationType
communityId: model.message.communityId
replyMessageIndex: chatsModel.messageView.getMessageIndex(model.chatId, model.responseTo)
repliedMessageContent: replyMessageIndex > -1 ? chatsModel.messageView.getMessageData(chatId, replyMessageIndex, "message") : ""
replyMessageIndex: root.store.chatsModelInst.messageView.getMessageIndex(model.chatId, model.responseTo)
repliedMessageContent: replyMessageIndex > -1 ? root.store.chatsModelInst.messageView.getMessageData(chatId, replyMessageIndex, "message") : ""
realChatType: {
var chatType = chatsModel.channelView.chats.getChannelType(model.chatId)
var chatType = root.store.chatsModelInst.channelView.chats.getChannelType(model.chatId)
if (chatType === Constants.chatTypeCommunity) {
// TODO add a check for private community chats once it is created
return Constants.chatTypePublic
@ -239,22 +237,22 @@ Item {
return chatType
}
profileImage: realChatType === Constants.chatTypeOneToOne ? appMain.getProfileImage(chatId) || "" : ""
channelName: chatsModel.getChannelNameById(badge.chatId)
communityName: root.communityIndex > -1 ? chatsModel.communities.joinedCommunities.rowData(root.communityIndex, "name") : ""
communityThumbnailImage: root.communityIndex > -1 ? chatsModel.communities.joinedCommunities.rowData(root.communityIndex, "thumbnailImage") : ""
communityColor: !model.image && root.communityIndex > -1 ? chatsModel.communities.joinedCommunities.rowData(root.communityIndex, "communityColor"): ""
channelName: root.store.chatsModelInst.getChannelNameById(badge.chatId)
communityName: root.communityIndex > -1 ? root.store.chatsModelInst.communities.joinedCommunities.rowData(root.communityIndex, "name") : ""
communityThumbnailImage: root.communityIndex > -1 ? root.store.chatsModelInst.communities.joinedCommunities.rowData(root.communityIndex, "thumbnailImage") : ""
communityColor: !model.image && root.communityIndex > -1 ? root.store.chatsModelInst.communities.joinedCommunities.rowData(root.communityIndex, "communityColor"): ""
onCommunityNameClicked: {
chatsModel.communities.setActiveCommunity(badge.communityId)
root.store.chatsModelInst.communities.setActiveCommunity(badge.communityId)
}
onChannelNameClicked: {
chatsModel.communities.setActiveCommunity(badge.communityId)
chatsModel.setActiveChannel(badge.chatId)
root.store.chatsModelInst.communities.setActiveCommunity(badge.communityId)
root.store.chatsModelInst.setActiveChannel(badge.chatId)
}
Connections {
enabled: badge.realChatType === Constants.chatTypeOneToOne
target: profileModel.contacts.list
target: root.store.profileModelInst.contacts.list
onContactChanged: {
if (pubkey === badge.chatId) {
badge.profileImage = appMain.getProfileImage(badge.chatId)

View File

@ -5,33 +5,33 @@ import "../../../../shared/panels"
import utils 1.0
Column {
property string authorCurrentMsg: "authorCurrentMsg"
property string profileImage
id: channelIdentifier
id: root
spacing: Style.current.padding
visible: authorCurrentMsg === ""
anchors.horizontalCenter: parent.horizontalCenter
topPadding: visible ? Style.current.bigPadding : 0
bottomPadding: visible? 50 : 0
property var store
property string authorCurrentMsg: "authorCurrentMsg"
property string profileImage
Rectangle {
id: circleId
anchors.horizontalCenter: parent.horizontalCenter
width: 120
height: 120
radius: 120
border.width: chatsModel.channelView.activeChannel.chatType === Constants.chatTypeOneToOne ? 2 : 0
border.width: root.store.chatsModelInst.channelView.activeChannel.chatType === Constants.chatTypeOneToOne ? 2 : 0
border.color: Style.current.border
color: {
if (chatsModel.channelView.activeChannel.chatType === Constants.chatTypeOneToOne) {
if (root.store.chatsModelInst.channelView.activeChannel.chatType === Constants.chatTypeOneToOne) {
return Style.current.transparent
}
if (chatsModel.channelView.activeChannel.color) {
return chatsModel.channelView.activeChannel.color
if (root.store.chatsModelInst.channelView.activeChannel.color) {
return root.store.chatsModelInst.channelView.activeChannel.color
}
const color = chatsModel.channelView.getChannelColor(chatId)
const color = root.store.chatsModelInst.channelView.getChannelColor(chatId)
if (!color) {
return Style.current.orange
}
@ -39,19 +39,21 @@ Column {
}
RoundedImage {
visible: chatsModel.channelView.activeChannel.chatType === Constants.chatTypeOneToOne
visible: root.store.chatsModelInst.channelView.activeChannel.chatType === Constants.chatTypeOneToOne
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
width: 120
height: 120
source: channelIdentifier.profileImage || chatsModel.channelView.activeChannel.identicon
source: root.profileImage || root.store.chatsModelInst.channelView.activeChannel.identicon
smooth: false
antialiasing: true
}
StyledText {
visible: chatsModel.channelView.activeChannel.chatType !== Constants.chatTypeOneToOne
text: Utils.removeStatusEns((chatsModel.channelView.activeChannel.name.charAt(0) === "#" ? chatsModel.channelView.activeChannel.name.charAt(1) : chatsModel.channelView.activeChannel.name.charAt(0)).toUpperCase())
visible: root.store.chatsModelInst.channelView.activeChannel.chatType !== Constants.chatTypeOneToOne
text: Utils.removeStatusEns((root.store.chatsModelInst.channelView.activeChannel.name.charAt(0) === "#" ?
root.store.chatsModelInst.channelView.activeChannel.name.charAt(1) :
root.store.chatsModelInst.channelView.activeChannel.name.charAt(0)).toUpperCase())
opacity: 0.7
font.weight: Font.Bold
font.pixelSize: 51
@ -65,10 +67,10 @@ Column {
id: channelName
wrapMode: Text.Wrap
text: {
switch(chatsModel.channelView.activeChannel.chatType) {
case Constants.chatTypePublic: return "#" + chatsModel.channelView.activeChannel.name;
case Constants.chatTypeOneToOne: return Utils.removeStatusEns(chatsModel.userNameOrAlias(chatsModel.channelView.activeChannel.id))
default: return chatsModel.channelView.activeChannel.name
switch(root.store.chatsModelInst.channelView.activeChannel.chatType) {
case Constants.chatTypePublic: return "#" + root.store.chatsModelInst.channelView.activeChannel.name;
case Constants.chatTypeOneToOne: return Utils.removeStatusEns(root.store.chatsModelInst.userNameOrAlias(chatsModel.channelView.activeChannel.id))
default: return root.store.chatsModelInst.channelView.activeChannel.name
}
}
font.weight: Font.Bold
@ -83,9 +85,9 @@ Column {
anchors.horizontalCenter: parent.horizontalCenter
width: 310
text: {
switch(chatsModel.channelView.activeChannel.chatType) {
switch(root.store.chatsModelInst.channelView.activeChannel.chatType) {
//% "Welcome to the beginning of the <span style='color: %1'>%2</span> group!"
case Constants.chatTypePrivateGroupChat: return qsTrId("welcome-to-the-beginning-of-the--span-style--color---1---2--span--group-").arg(Style.current.textColor).arg(chatsModel.channelView.activeChannel.name);
case Constants.chatTypePrivateGroupChat: return qsTrId("welcome-to-the-beginning-of-the--span-style--color---1---2--span--group-").arg(Style.current.textColor).arg(root.store.chatsModelInst.channelView.activeChannel.name);
//% "Any messages you send here are encrypted and can only be read by you and <span style='color: %1'>%2</span>"
case Constants.chatTypeOneToOne: return qsTrId("any-messages-you-send-here-are-encrypted-and-can-only-be-read-by-you-and--span-style--color---1---2--span-").arg(Style.current.textColor).arg(channelName.text)
default: return "";
@ -98,7 +100,8 @@ Column {
}
Item {
visible: chatsModel.channelView.activeChannel.chatType === Constants.chatTypePrivateGroupChat && chatsModel.channelView.activeChannel.isMemberButNotJoined
visible: root.store.chatsModelInst.channelView.activeChannel.chatType === Constants.chatTypePrivateGroupChat
&& root.store.chatsModelInst.channelView.activeChannel.isMemberButNotJoined
anchors.horizontalCenter: parent.horizontalCenter
width: visible ? joinChat.width : 0
height: visible ? 100 : 0
@ -116,7 +119,7 @@ Column {
cursorShape: Qt.PointingHandCursor
anchors.fill: parent
onClicked: {
chatsModel.groups.join()
root.store.chatsModelInst.groups.join()
}
}
}
@ -133,7 +136,7 @@ Column {
cursorShape: Qt.PointingHandCursor
anchors.fill: parent
onClicked: {
chatsModel.channelView.leaveActiveChat()
root.store.chatsModelInst.channelView.leaveActiveChat()
}
}
}

View File

@ -22,7 +22,7 @@ import "../panels"
import "../../Wallet"
Item {
id: chatColumnLayout
id: root
anchors.fill: parent
property var rootStore
property alias pinnedMessagesPopupComponent: pinnedMessagesPopupComponent
@ -32,10 +32,10 @@ Item {
property bool isExtendedInput: isReply || isImage
property bool isConnected: false
property string contactToRemove: ""
property string activeChatId: chatsModel.channelView.activeChannel.id
property bool isBlocked: profileModel.contacts.isContactBlocked(activeChatId)
property bool isContact: profileModel.contacts.isAdded(activeChatId)
property bool contactRequestReceived: profileModel.contacts.contactRequestReceived(activeChatId)
property string activeChatId: root.rootStore.chatsModelInst.channelView.activeChannel.id
property bool isBlocked: root.rootStore.profileModelInst.contacts.isContactBlocked(activeChatId)
property bool isContact: root.rootStore.profileModelInst.contacts.isAdded(activeChatId)
property bool contactRequestReceived: root.rootStore.profileModelInst.contacts.contactRequestReceived(activeChatId)
property string currentNotificationChatId
property string currentNotificationCommunityId
property var currentTime: 0
@ -55,30 +55,30 @@ Item {
function showReplyArea() {
isReply = true;
isImage = false;
let replyMessageIndex = chatsModel.messageView.messageList.getMessageIndex(SelectedMessage.messageId);
let replyMessageIndex = root.rootStore.chatsModelInst.messageView.messageList.getMessageIndex(SelectedMessage.messageId);
if (replyMessageIndex === -1) return;
let userName = chatsModel.messageView.messageList.getMessageData(replyMessageIndex, "userName")
let message = chatsModel.messageView.messageList.getMessageData(replyMessageIndex, "message")
let identicon = chatsModel.messageView.messageList.getMessageData(replyMessageIndex, "identicon")
let image = chatsModel.messageView.messageList.getMessageData(replyMessageIndex, "image")
let sticker = chatsModel.messageView.messageList.getMessageData(replyMessageIndex, "sticker")
let contentType = chatsModel.messageView.messageList.getMessageData(replyMessageIndex, "contentType")
let userName = root.rootStore.chatsModelInst.messageView.messageList.getMessageData(replyMessageIndex, "userName")
let message = root.rootStore.chatsModelInst.messageView.messageList.getMessageData(replyMessageIndex, "message")
let identicon = root.rootStore.chatsModelInst.messageView.messageList.getMessageData(replyMessageIndex, "identicon")
let image = root.rootStore.chatsModelInst.messageView.messageList.getMessageData(replyMessageIndex, "image")
let sticker = root.rootStore.chatsModelInst.messageView.messageList.getMessageData(replyMessageIndex, "sticker")
let contentType = root.rootStore.chatsModelInst.messageView.messageList.getMessageData(replyMessageIndex, "contentType")
if(stackLayoutChatMessages.currentIndex >= 0 && stackLayoutChatMessages.currentIndex < stackLayoutChatMessages.children.length)
stackLayoutChatMessages.children[stackLayoutChatMessages.currentIndex].chatInput.showReplyArea(userName, message, identicon, contentType, image, sticker)
}
function requestAddressForTransaction(address, amount, tokenAddress, tokenDecimals = 18) {
amount = utilsModel.eth2Wei(amount.toString(), tokenDecimals)
chatsModel.transactions.requestAddress(activeChatId,
amount = root.rootStore.utilsModelInst.eth2Wei(amount.toString(), tokenDecimals)
root.rootStore.chatsModelInst.transactions.requestAddress(activeChatId,
address,
amount,
tokenAddress)
txModalLoader.close()
}
function requestTransaction(address, amount, tokenAddress, tokenDecimals = 18) {
amount = utilsModel.eth2Wei(amount.toString(), tokenDecimals)
chatsModel.transactions.request(activeChatId,
amount = root.rootStore.utilsModelInst.eth2Wei(amount.toString(), tokenDecimals)
root.rootStore.chatsModelInst.transactions.request(activeChatId,
address,
amount,
tokenAddress)
@ -106,19 +106,20 @@ Item {
repeat: true
triggeredOnStart: true
onTriggered: {
chatColumnLayout.currentTime = Date.now()
root.currentTime = Date.now()
}
}
MessageContextMenuView {
id: contextmenu
store: chatColumnLayout.rootStore
reactionModel: chatColumnLayout.rootStore.emojiReactionsModel
store: root.rootStore
reactionModel: root.rootStore.emojiReactionsModel
}
StackLayout {
anchors.fill: parent
currentIndex: chatsModel.channelView.activeChannelIndex > -1 && chatGroupsListViewCount > 0 ? 0 : 1
currentIndex: root.rootStore.chatsModelInst.channelView.activeChannelIndex > -1
&& chatGroupsListViewCount > 0 ? 0 : 1
StatusImageModal {
id: imagePopup
@ -142,14 +143,14 @@ Item {
id: topBar
Layout.fillWidth: true
property string chatId: chatsModel.channelView.activeChannel.id
property string chatId: root.rootStore.chatsModelInst.channelView.activeChannel.id
property string profileImage: appMain.getProfileImage(chatId) || ""
chatInfoButton.title: Utils.removeStatusEns(chatsModel.channelView.activeChannel.name)
chatInfoButton.title: Utils.removeStatusEns(root.rootStore.chatsModelInst.channelView.activeChannel.name)
chatInfoButton.subTitle: {
switch (chatsModel.channelView.activeChannel.chatType) {
switch (root.rootStore.chatsModelInst.channelView.activeChannel.chatType) {
case Constants.chatTypeOneToOne:
return (profileModel.contacts.isAdded(topBar.chatId) ?
return (root.rootStore.profileModelInst.contacts.isAdded(topBar.chatId) ?
//% "Contact"
qsTrId("chat-is-a-contact") :
//% "Not a contact"
@ -158,51 +159,52 @@ Item {
//% "Public chat"
return qsTrId("public-chat")
case Constants.chatTypePrivateGroupChat:
let cnt = chatsModel.channelView.activeChannel.members.rowCount();
let cnt = root.rootStore.chatsModelInst.channelView.activeChannel.members.rowCount();
//% "%1 members"
if(cnt > 1) return qsTrId("-1-members").arg(cnt);
//% "1 member"
return qsTrId("1-member");
case Constants.chatTypeCommunity:
return Utils.linkifyAndXSS(chatsModel.channelView.activeChannel.description).trim()
return Utils.linkifyAndXSS(root.rootStore.chatsModelInst.channelView.activeChannel.description).trim()
default:
return ""
}
}
chatInfoButton.image.source: profileImage || chatsModel.channelView.activeChannel.identicon
chatInfoButton.image.isIdenticon: !!!profileImage && chatsModel.channelView.activeChannel.identicon
chatInfoButton.icon.color: chatsModel.channelView.activeChannel.color
chatInfoButton.type: chatsModel.channelView.activeChannel.chatType
chatInfoButton.pinnedMessagesCount: chatsModel.messageView.pinnedMessagesList.count
chatInfoButton.muted: chatsModel.channelView.activeChannel.muted
chatInfoButton.image.source: profileImage || root.rootStore.chatsModelInst.channelView.activeChannel.identicon
chatInfoButton.image.isIdenticon: !!!profileImage && root.rootStore.chatsModelInst.channelView.activeChannel.identicon
chatInfoButton.icon.color: root.rootStore.chatsModelInst.channelView.activeChannel.color
chatInfoButton.type: root.rootStore.chatsModelInst.channelView.activeChannel.chatType
chatInfoButton.pinnedMessagesCount: root.rootStore.chatsModelInst.messageView.pinnedMessagesList.count
chatInfoButton.muted: root.rootStore.chatsModelInst.channelView.activeChannel.muted
chatInfoButton.onPinnedMessagesCountClicked: openPopup(pinnedMessagesPopupComponent)
chatInfoButton.onUnmute: chatsModel.channelView.unmuteChatItem(chatsModel.channelView.activeChannel.id)
chatInfoButton.onUnmute: root.rootStore.chatsModelInst.channelView.unmuteChatItem(chatsModel.channelView.activeChannel.id)
chatInfoButton.sensor.enabled: chatsModel.channelView.activeChannel.chatType !== Constants.chatTypePublic &&
chatsModel.channelView.activeChannel.chatType !== Constants.chatTypeCommunity
chatInfoButton.sensor.enabled: root.rootStore.chatsModelInst.channelView.activeChannel.chatType !== Constants.chatTypePublic &&
root.rootStore.chatsModelInst.channelView.activeChannel.chatType !== Constants.chatTypeCommunity
chatInfoButton.onClicked: {
switch (chatsModel.channelView.activeChannel.chatType) {
switch (root.rootStore.chatsModelInst.channelView.activeChannel.chatType) {
case Constants.chatTypePrivateGroupChat:
openPopup(groupInfoPopupComponent, {
channelType: GroupInfoPopup.ChannelType.ActiveChannel,
channel: chatsModel.channelView.activeChannel
channel: root.rootStore.chatsModelInst.channelView.activeChannel
})
break;
case Constants.chatTypeOneToOne:
openProfilePopup(chatsModel.userNameOrAlias(chatsModel.channelView.activeChannel.id),
chatsModel.channelView.activeChannel.id, profileImage || chatsModel.channelView.activeChannel.identicon,
"", chatsModel.channelView.activeChannel.nickname)
openProfilePopup(root.rootStore.chatsModelInst.userNameOrAlias(chatsModel.channelView.activeChannel.id),
root.rootStore.chatsModelInst.channelView.activeChannel.id, profileImage
|| root.rootStore.chatsModelInst.channelView.activeChannel.identicon,
"", root.rootStore.chatsModelInst.channelView.activeChannel.nickname)
break;
}
}
membersButton.visible: (appSettings.showOnlineUsers || chatsModel.communities.activeCommunity.active)
&& chatsModel.channelView.activeChannel.chatType !== Constants.chatTypeOneToOne
membersButton.visible: (appSettings.showOnlineUsers || root.rootStore.chatsModelInst.communities.activeCommunity.active)
&& root.rootStore.chatsModelInst.channelView.activeChannel.chatType !== Constants.chatTypeOneToOne
membersButton.highlighted: appSettings.expandUsersList
notificationButton.visible: appSettings.isActivityCenterEnabled
notificationButton.tooltip.offset: appSettings.expandUsersList ? 0 : 14
notificationCount: chatsModel.activityNotificationList.unreadCount
notificationCount: root.rootStore.chatsModelInst.activityNotificationList.unreadCount
onSearchButtonClicked: searchPopup.open()
@ -210,8 +212,9 @@ Item {
onNotificationButtonClicked: activityCenter.open()
popupMenu: ChatContextMenuView {
store: root.rootStore
onOpened: {
chatItem = chatsModel.channelView.activeChannel
chatItem = root.rootStore.chatsModelInst.channelView.activeChannel
}
}
}
@ -237,7 +240,7 @@ Item {
}
Connections {
target: chatsModel
target: root.rootStore.chatsModelInst
onOnlineStatusChanged: {
if (connected == isConnected) return;
isConnected = connected;
@ -251,7 +254,7 @@ Item {
}
}
Component.onCompleted: {
isConnected = chatsModel.isOnline
isConnected = root.rootStore.chatsModelInst.isOnline
if(!isConnected){
connectedStatusRect.visible = true
}
@ -284,9 +287,9 @@ Item {
Layout.fillWidth: true
Layout.fillHeight: true
clip: true
currentIndex: chatsModel.messageView.getMessageListIndex(chatsModel.channelView.activeChannelIndex)
currentIndex: root.rootStore.chatsModelInst.messageView.getMessageListIndex(root.rootStore.chatsModelInst.channelView.activeChannelIndex)
Repeater {
model: chatsModel.messageView
model: root.rootStore.chatsModelInst.messageView
ColumnLayout {
property alias chatInput: chatInput
property alias message: messageLoader.item
@ -300,11 +303,11 @@ Item {
active: stackLayoutChatMessages.currentIndex === index
sourceComponent: ChatMessagesView {
id: chatMessages
store: chatColumnLayout.rootStore
store: root.rootStore
messageList: messages
messageContextMenuInst: contextmenu
Component.onCompleted: {
chatColumnLayout.userList = chatMessages.messageList.userList;
root.userList = chatMessages.messageList.userList;
}
}
}
@ -317,7 +320,7 @@ Item {
Layout.preferredHeight: height
Connections {
target: chatsModel.messageView
target: root.rootStore.chatsModelInst.messageView
onLoadingMessagesChanged:
if(value){
loadingMessagesIndicator.active = true
@ -330,7 +333,7 @@ Item {
Loader {
id: loadingMessagesIndicator
active: chatsModel.messageView.loadingMessages
active: root.rootStore.chatsModelInst.messageView.loadingMessages
sourceComponent: loadingIndicator
anchors.right: parent.right
anchors.bottom: chatInput.top
@ -346,17 +349,17 @@ Item {
StatusChatInput {
id: chatInput
visible: {
if (chatsModel.channelView.activeChannel.chatType === Constants.chatTypePrivateGroupChat) {
return chatsModel.channelView.activeChannel.isMember
if (root.rootStore.chatsModelInst.channelView.activeChannel.chatType === Constants.chatTypePrivateGroupChat) {
return root.rootStore.chatsModelInst.channelView.activeChannel.isMember
}
if (chatsModel.channelView.activeChannel.chatType === Constants.chatTypeOneToOne) {
if (root.rootStore.chatsModelInst.channelView.activeChannel.chatType === Constants.chatTypeOneToOne) {
return isContact
}
const community = chatsModel.communities.activeCommunity
const community = root.rootStore.chatsModelInst.communities.activeCommunity
return !community.active ||
community.access === Constants.communityChatPublicAccess ||
community.admin ||
chatsModel.channelView.activeChannel.canPost
root.rootStore.chatsModelInst.channelView.activeChannel.canPost
}
isContactBlocked: isBlocked
chatInputPlaceholder: isBlocked ?
@ -365,11 +368,11 @@ Item {
//% "Type a message."
qsTrId("type-a-message-")
anchors.bottom: parent.bottom
recentStickers: chatsModel.stickers.recent
stickerPackList: chatsModel.stickers.stickerPacks
chatType: chatsModel.channelView.activeChannel.chatType
recentStickers: root.rootStore.chatsModelInst.stickers.recent
stickerPackList: root.rootStore.chatsModelInst.stickers.stickerPacks
chatType: root.rootStore.chatsModelInst.channelView.activeChannel.chatType
onSendTransactionCommandButtonClicked: {
if (chatsModel.channelView.activeChannel.ensVerified) {
if (root.rootStore.chatsModelInst.channelView.activeChannel.ensVerified) {
txModalLoader.sourceComponent = cmpSendTransactionWithEns
} else {
txModalLoader.sourceComponent = cmpSendTransactionNoEns
@ -381,16 +384,16 @@ Item {
txModalLoader.item.open()
}
onStickerSelected: {
chatsModel.stickers.send(hashId, chatInput.isReply ? SelectedMessage.messageId : "", packId)
root.rootStore.chatsModelInst.stickers.send(hashId, chatInput.isReply ? SelectedMessage.messageId : "", packId)
}
onSendMessage: {
if (chatInput.fileUrls.length > 0){
chatsModel.sendImages(JSON.stringify(fileUrls));
root.rootStore.chatsModelInst.sendImages(JSON.stringify(fileUrls));
}
let msg = chatsModel.plainText(Emoji.deparse(chatInput.textInput.text))
let msg = root.rootStore.chatsModelInst.plainText(Emoji.deparse(chatInput.textInput.text))
if (msg.length > 0){
msg = chatInput.interpretMessage(msg)
chatsModel.messageView.sendMessage(msg, chatInput.isReply ? SelectedMessage.messageId : "", Utils.isOnlyEmoji(msg) ? Constants.emojiType : Constants.messageType, false);
root.rootStore.chatsModelInst.messageView.sendMessage(msg, chatInput.isReply ? SelectedMessage.messageId : "", Utils.isOnlyEmoji(msg) ? Constants.emojiType : Constants.messageType, false);
if(event) event.accepted = true
sendMessageSound.stop();
Qt.callLater(sendMessageSound.play);
@ -403,9 +406,9 @@ Item {
}
}
Connections {
target: chatsModel.channelView
target: root.rootStore.chatsModelInst.channelView
onActiveChannelChanged: {
isBlocked = profileModel.contacts.isContactBlocked(activeChatId);
isBlocked = root.rootStore.profileModelInst.contacts.isContactBlocked(activeChatId);
chatInput.suggestions.hide();
if(stackLayoutChatMessages.currentIndex >= 0 && stackLayoutChatMessages.currentIndex < stackLayoutChatMessages.children.length)
stackLayoutChatMessages.children[stackLayoutChatMessages.currentIndex].chatInput.textInput.forceActiveFocus(Qt.MouseFocusReason)
@ -419,13 +422,13 @@ Item {
Layout.alignment: Qt.AlignHCenter | Qt.AlignBottom
Layout.fillWidth: true
Layout.bottomMargin: Style.current.bigPadding
visible: chatsModel.channelView.activeChannel.chatType === Constants.chatTypeOneToOne && (!isContact /*|| !contactRequestReceived*/)
onAddContactClicked: profileModel.contacts.addContact(activeChatId)
visible: root.rootStore.chatsModelInst.channelView.activeChannel.chatType === Constants.chatTypeOneToOne && (!isContact /*|| !contactRequestReceived*/)
onAddContactClicked: root.rootStore.profileModelInst.contacts.addContact(activeChatId)
}
}
EmptyChatPanel {
onShareChatKeyClicked: openProfilePopup(profileModel.profile.username, profileModel.profile.pubKey, profileModel.profile.thumbnailImage);
onShareChatKeyClicked: openProfilePopup(root.rootStore.profileModelInst.profile.username, root.rootStore.profileModelInst.profile.pubKey, root.rootStore.profileModelInst.profile.thumbnailImage);
}
Loader {
@ -449,7 +452,7 @@ Item {
onClosed: {
txModalLoader.closed()
}
sendChatCommand: chatColumnLayout.requestAddressForTransaction
sendChatCommand: root.requestAddressForTransaction
isRequested: false
//% "Send"
commandTitle: qsTrId("command-button-send")
@ -459,9 +462,9 @@ Item {
selectRecipient.selectedRecipient: {
return {
address: Constants.zeroAddress, // Setting as zero address since we don't have the address yet
alias: chatsModel.channelView.activeChannel.alias,
identicon: chatsModel.channelView.activeChannel.identicon,
name: chatsModel.channelView.activeChannel.name,
alias: root.rootStore.chatsModelInst.channelView.activeChannel.alias,
identicon: root.rootStore.chatsModelInst.channelView.activeChannel.identicon,
name: root.rootStore.chatsModelInst.channelView.activeChannel.name,
type: RecipientSelector.Type.Contact
}
}
@ -477,7 +480,7 @@ Item {
onClosed: {
txModalLoader.closed()
}
sendChatCommand: chatColumnLayout.requestTransaction
sendChatCommand: root.requestTransaction
isRequested: true
//% "Request"
commandTitle: qsTrId("wallet-request")
@ -487,9 +490,9 @@ Item {
selectRecipient.selectedRecipient: {
return {
address: Constants.zeroAddress, // Setting as zero address since we don't have the address yet
alias: chatsModel.channelView.activeChannel.alias,
identicon: chatsModel.channelView.activeChannel.identicon,
name: chatsModel.channelView.activeChannel.name,
alias: root.rootStore.chatsModelInst.channelView.activeChannel.alias,
identicon: root.rootStore.chatsModelInst.channelView.activeChannel.identicon,
name: root.rootStore.chatsModelInst.channelView.activeChannel.name,
type: RecipientSelector.Type.Contact
}
}
@ -503,7 +506,7 @@ Item {
SendModal {
id: sendTransactionWithEns
onOpened: {
walletModel.gasView.getGasPrice()
root.rootStore.walletModelInst.gasView.getGasPrice()
}
onClosed: {
txModalLoader.closed()
@ -512,9 +515,9 @@ Item {
selectRecipient.selectedRecipient: {
return {
address: "",
alias: chatsModel.channelView.activeChannel.alias,
identicon: chatsModel.channelView.activeChannel.identicon,
name: chatsModel.channelView.activeChannel.name,
alias: root.rootStore.chatsModelInst.channelView.activeChannel.alias,
identicon: root.rootStore.chatsModelInst.channelView.activeChannel.identicon,
name: root.rootStore.chatsModelInst.channelView.activeChannel.name,
type: RecipientSelector.Type.Contact,
ensVerified: true
}
@ -525,22 +528,22 @@ Item {
ActivityCenterPopup {
id: activityCenter
height: chatColumnLayout.height - (topBar.height * 2) // TODO get screen size
height: root.height - (topBar.height * 2) // TODO get screen size
y: topBar.height
store: chatColumnLayout.rootStore
store: root.rootStore
}
Connections {
target: profileModel.contacts
target: root.rootStore.profileModelInst.contacts
onContactListChanged: {
isBlocked = profileModel.contacts.isContactBlocked(activeChatId);
isBlocked = root.rootStore.profileModelInst.contacts.isContactBlocked(activeChatId);
}
}
Connections {
target: chatsModel.channelView
target: root.rootStore.chatsModelInst.channelView
onActiveChannelChanged: {
chatsModel.messageView.hideLoadingIndicator()
root.rootStore.chatsModelInst.messageView.hideLoadingIndicator()
SelectedMessage.reset();
chatColumn.isReply = false;
}
@ -557,14 +560,14 @@ Item {
id: pinnedMessagesPopupComponent
PinnedMessagesPopup {
id: pinnedMessagesPopup
rootStore: chatColumnLayout.rootStore
messageStore: chatColumnLayout.rootStore.messageStore
rootStore: root.rootStore
messageStore: root.rootStore.messageStore
onClosed: destroy()
}
}
Connections {
target: chatsModel.messageView
target: root.rootStore.chatsModelInst.messageView
onSearchedMessageLoaded: {
positionAtMessage(messageId, true);
@ -573,13 +576,13 @@ Item {
onMessageNotificationPushed: function(messageId, communityId, chatId, msg, contentType, chatType, timestamp, identicon, username, hasMention, isAddedContact, channelName) {
if (appSettings.notificationSetting == Constants.notifyAllMessages ||
(appSettings.notificationSetting == Constants.notifyJustMentions && hasMention)) {
if (chatId === chatsModel.channelView.activeChannel.id && applicationWindow.active === true) {
if (chatId === root.rootStore.chatsModelInst.channelView.activeChannel.id && applicationWindow.active === true) {
// Do not show the notif if we are in the channel already and the window is active and focused
return
}
chatColumnLayout.currentNotificationChatId = chatId
chatColumnLayout.currentNotificationCommunityId = null
root.currentNotificationChatId = chatId
root.currentNotificationCommunityId = null
let name;
if (appSettings.notificationMessagePreviewSetting === Constants.notificationPreviewAnonymous) {
@ -609,7 +612,7 @@ Item {
// Note:
// Show notification should be moved to the nim side.
// Left here only cause we don't have a way to deal with translations on the nim side.
chatsModel.showOSNotification(name,
root.rootStore.chatsModelInst.showOSNotification(name,
message,
Constants.osNotificationType.newMessage,
communityId,
@ -626,7 +629,7 @@ Item {
}
Connections {
target: chatsModel.stickers
target: root.rootStore.chatsModelInst.stickers
onTransactionWasSent: {
//% "Transaction pending..."
toastMessage.title = qsTr("Transaction pending...")

View File

@ -10,9 +10,10 @@ import "../../../../shared/popups"
import "../popups"
StatusPopupMenu {
id: root
property var chatItem
property bool communityActive: chatsModel.communities.activeCommunity.active
property var store
property bool communityActive: root.store.chatsModelInst.communities.activeCommunity.active
StatusMenuItem {
id: viewProfileMenuItem
@ -59,10 +60,10 @@ StatusPopupMenu {
Action {
enabled: profileModel.fleets.fleet == Constants.waku_prod || profileModel.fleets.fleet === Constants.waku_test
enabled: root.store.profileModelInst.fleets.fleet == Constants.waku_prod || root.store.profileModelInst.fleets.fleet === Constants.waku_test
//% "Test WakuV2 - requestAllHistoricMessages"
text: qsTrId("test-wakuv2---requestallhistoricmessages")
onTriggered: chatsModel.requestAllHistoricMessages()
onTriggered: root.store.chatsModelInst.requestAllHistoricMessages()
}
StatusMenuItem {
@ -75,9 +76,9 @@ StatusPopupMenu {
enabled: chatItem && chatItem.chatType !== Constants.chatTypePrivateGroupChat
onTriggered: {
if (chatItem && chatItem.muted) {
return chatsModel.channelView.unmuteChatItem(chatItem.id)
return root.store.chatsModelInst.channelView.unmuteChatItem(chatItem.id)
}
chatsModel.channelView.muteChatItem(chatItem.id)
root.store.chatsModelInst.channelView.muteChatItem(chatItem.id)
}
}
@ -86,14 +87,14 @@ StatusPopupMenu {
text: qsTrId("mark-as-read")
icon.name: "checkmark-circle"
enabled: chatItem && chatItem.chatType !== Constants.chatTypePrivateGroupChat
onTriggered: chatsModel.channelView.markChatItemAsRead(chatItem.id)
onTriggered: root.store.chatsModelInst.channelView.markChatItemAsRead(chatItem.id)
}
StatusMenuItem {
//% "Clear history"
text: qsTrId("clear-history")
icon.name: "close-circle"
onTriggered: chatsModel.channelView.clearChatHistory(chatItem.id)
onTriggered: root.store.chatsModelInst.channelView.clearChatHistory(chatItem.id)
}
StatusMenuItem {
@ -101,9 +102,9 @@ StatusPopupMenu {
text: qsTrId("edit-channel")
icon.name: "edit"
enabled: communityActive &&
chatsModel.communities.activeCommunity.admin
root.store.chatsModelInst.communities.activeCommunity.admin
onTriggered: openPopup(editChannelPopup, {
communityId: chatsModel.communities.activeCommunity.id,
communityId: root.store.chatsModelInst.communities.activeCommunity.id,
channel: chatItem
})
}
@ -140,7 +141,7 @@ StatusPopupMenu {
openPopup(deleteChatConfirmationDialogComponent)
}
enabled: !communityActive || chatsModel.communities.activeCommunity.admin
enabled: !communityActive || root.store.chatsModelInst.communities.activeCommunity.admin
}
FileDialog {
@ -151,7 +152,7 @@ StatusPopupMenu {
currentFile: StandardPaths.writableLocation(StandardPaths.DocumentsLocation) + "/messages.json"
defaultSuffix: "json"
onAccepted: {
chatsModel.messageView.downloadMessages(downdloadDialog.currentFile)
root.store.chatsModelInst.messageView.downloadMessages(downdloadDialog.currentFile)
}
}
@ -181,9 +182,9 @@ StatusPopupMenu {
}
onConfirmButtonClicked: {
if (communityActive) {
chatsModel.communities.deleteCommunityChat(chatsModel.communities.activeCommunity.id, chatId)
root.store.chatsModelInst.communities.deleteCommunityChat(root.store.chatsModelInst.communities.activeCommunity.id, chatId)
} else {
chatsModel.channelView.leaveChat(chatId)
root.store.chatsModelInst.channelView.leaveChat(chatId)
}
close();
}

View File

@ -21,6 +21,7 @@ Item {
anchors.fill: parent
property var store
property alias chatLogView: chatLogView
property alias scrollToMessage: chatLogView.scrollToMessage
@ -183,7 +184,7 @@ Item {
}
Connections {
target: chatsModel
target: root.store.chatsModelInst
onAppReady: {
chatLogView.scrollToBottom(true)
@ -191,7 +192,7 @@ Item {
}
Connections {
target: chatsModel.messageView
target: root.store.chatsModelInst.messageView
onSendingMessageSuccess: {
chatLogView.scrollToBottom(true)
@ -209,7 +210,7 @@ Item {
}
Connections {
target: chatsModel.communities
target: root.store.chatsModelInst.communities
// Note:
// Whole this Connection object (both slots) should be moved to the nim side.
@ -218,7 +219,7 @@ Item {
onMembershipRequestChanged: function (communityId, communityName, accepted) {
chatColumnLayout.currentNotificationChatId = null
chatColumnLayout.currentNotificationCommunityId = communityId
chatsModel.showOSNotification("Status",
root.store.chatsModelInst.showOSNotification("Status",
//% "You have been accepted into the %1 community"
accepted ? qsTrId("you-have-been-accepted-into-the---1--community").arg(communityName) :
//% "Your request to join the %1 community was declined"
@ -235,7 +236,7 @@ Item {
chatColumnLayout.currentNotificationChatId = null
chatColumnLayout.currentNotificationCommunityId = communityId
//% "New membership request"
chatsModel.showOSNotification(qsTrId("new-membership-request"),
root.store.chatsModelInst.showOSNotification(qsTrId("new-membership-request"),
//% "%1 asks to join %2"
qsTrId("-1-asks-to-join---2-").arg(Utils.getDisplayName(pubKey)).arg(communityName),
Constants.osNotificationType.joinCommunityRequest,
@ -250,7 +251,7 @@ Item {
if(!messages.initialMessagesLoaded || messages.loadingHistoryMessages)
return
chatsModel.messageView.loadMoreMessages(chatId);
root.store.chatsModelInst.messageView.loadMoreMessages(chatId);
});
onContentYChanged: {

View File

@ -11,8 +11,8 @@ Item {
property var store
property var messageStore
property bool longChatText: true
property bool veryLongChatText: chatsModel.plainText(message).length >
(appSettings.useCompactMode ? Constants.limitLongChatTextCompactMode : Constants.limitLongChatText)
property bool veryLongChatText: !!root.store ? root.store.chatsModelInst.plainText(message).length >
(appSettings.useCompactMode ? Constants.limitLongChatTextCompactMode : Constants.limitLongChatText) : false
property bool readMore: false
property alias textField: chatText
@ -55,14 +55,14 @@ Item {
root.linkActivated(link)
if(link.startsWith("#")) {
const channelName = link.substring(1);
const foundChannelObj = chatsModel.getChannel(channelName);
const foundChannelObj = root.store.chatsModelInst.getChannel(channelName);
if (!foundChannelObj)
{
chatsModel.channelView.joinPublicChat(channelName)
if(chatsModel.communities.activeCommunity.active)
root.store.chatsModelInst.channelView.joinPublicChat(channelName)
if(root.store.chatsModelInst.communities.activeCommunity.active)
{
chatsModel.channelView.joinPublicChat(channelName)
root.store.chatsModelInst.channelView.joinPublicChat(channelName)
appMain.changeAppSection(Constants.chat)
}
return
@ -72,20 +72,18 @@ Item {
if(obj.chatType === -1 || obj.chatType === Constants.chatTypePublic)
{
if(chatsModel.communities.activeCommunity.active)
{
chatsModel.channelView.joinPublicChat(channelName)
if(root.store.chatsModelInst.communities.activeCommunity.active) {
root.store.chatsModelInst.channelView.joinPublicChat(channelName)
appMain.changeAppSection(Constants.chat)
}
chatsModel.channelView.setActiveChannel(channelName);
root.store.chatsModelInst.channelView.setActiveChannel(channelName);
}
else if(obj.communityId === chatsModel.communities.activeCommunity.id &&
else if(obj.communityId === root.store.chatsModelInst.communities.activeCommunity.id &&
obj.chatType === Constants.chatTypeCommunity &&
chatsModel.channelView.activeChannel.id !== obj.id
root.store.chatsModelInst.channelView.activeChannel.id !== obj.id
)
{
chatsModel.channelView.setActiveChannel(channelName);
root.store.chatsModelInst.channelView.setActiveChannel(channelName);
}
return
@ -94,7 +92,7 @@ Item {
if (link.startsWith('//')) {
let pk = link.replace("//", "");
const userProfileImage = appMain.getProfileImage(pk)
openProfilePopup(chatsModel.userNameOrAlias(pk), pk, userProfileImage || utilsModel.generateIdenticon(pk))
openProfilePopup(root.store.chatsModelInst.userNameOrAlias(pk), pk, userProfileImage || root.store.utilsModelInst.generateIdenticon(pk))
return;
}

View File

@ -20,27 +20,27 @@ Item {
width: 304
height: parent.height
property var store
// TODO unhardcode
property int chatGroupsListViewCount: communityChatListAndCategories.chatList.count
property Component pinnedMessagesPopupComponent
property var rootStore
StatusChatInfoToolBar {
id: communityHeader
anchors.top: parent.top
anchors.horizontalCenter: parent.horizontalCenter
chatInfoButton.title: chatsModel.communities.activeCommunity.name
chatInfoButton.subTitle: chatsModel.communities.activeCommunity.nbMembers === 1 ?
chatInfoButton.title: root.store.chatsModelInst.communities.activeCommunity.name
chatInfoButton.subTitle: root.store.chatsModelInst.communities.activeCommunity.nbMembers === 1 ?
//% "1 Member"
qsTrId("1-member") :
//% "%1 Members"
qsTrId("-1-members").arg(chatsModel.communities.activeCommunity.nbMembers)
chatInfoButton.image.source: chatsModel.communities.activeCommunity.thumbnailImage
chatInfoButton.icon.color: chatsModel.communities.activeCommunity.communityColor
menuButton.visible: chatsModel.communities.activeCommunity.admin && chatsModel.communities.activeCommunity.canManageUsers
qsTrId("-1-members").arg(root.store.chatsModelInst.communities.activeCommunity.nbMembers)
chatInfoButton.image.source: root.store.chatsModelInst.communities.activeCommunity.thumbnailImage
chatInfoButton.icon.color: root.store.chatsModelInst.communities.activeCommunity.communityColor
menuButton.visible: root.store.chatsModelInst.communities.activeCommunity.admin && root.store.chatsModelInst.communities.activeCommunity.canManageUsers
chatInfoButton.onClicked: openPopup(communityProfilePopup, {
community: chatsModel.communities.activeCommunity
community: root.store.chatsModelInst.communities.activeCommunity
})
popupMenu: StatusPopupMenu {
@ -48,7 +48,7 @@ Item {
//% "Create channel"
text: qsTrId("create-channel")
icon.name: "channel"
enabled: chatsModel.communities.activeCommunity.admin
enabled: root.store.chatsModelInst.communities.activeCommunity.admin
onTriggered: openPopup(createChannelPopup, {communityId: chatsModel.communities.activeCommunity.id})
}
@ -56,7 +56,7 @@ Item {
//% "Create category"
text: qsTrId("create-category")
icon.name: "channel-category"
enabled: chatsModel.communities.activeCommunity.admin
enabled: root.store.chatsModelInst.communities.activeCommunity.admin
onTriggered: openPopup(createCategoryPopup, {communityId: chatsModel.communities.activeCommunity.id})
}
@ -66,9 +66,9 @@ Item {
//% "Invite people"
text: qsTrId("invite-people")
icon.name: "share-ios"
enabled: chatsModel.communities.activeCommunity.canManageUsers
enabled: root.store.chatsModelInst.communities.activeCommunity.canManageUsers
onTriggered: openPopup(inviteFriendsToCommunityPopup, {
community: chatsModel.communities.activeCommunity
community: root.store.chatsModelInst.communities.activeCommunity
})
}
}
@ -76,13 +76,13 @@ Item {
Loader {
id: membershipRequests
property int nbRequests: chatsModel.communities.activeCommunity.communityMembershipRequests.nbRequests
property int nbRequests: root.store.chatsModelInst.communities.activeCommunity.communityMembershipRequests.nbRequests
anchors.top: communityHeader.bottom
anchors.topMargin: active ? 8 : 0
anchors.horizontalCenter: parent.horizontalCenter
active: chatsModel.communities.activeCommunity.admin && nbRequests > 0
active: root.store.chatsModelInst.communities.activeCommunity.admin && nbRequests > 0
height: nbRequests > 0 ? 64 : 0
sourceComponent: Component {
StatusContactRequestsIndicatorListItem {
@ -126,27 +126,27 @@ Item {
return implicitHeight
}
draggableItems: chatsModel.communities.activeCommunity.admin
draggableCategories: chatsModel.communities.activeCommunity.admin
chatList.model: chatsModel.communities.activeCommunity.chats
draggableItems: root.store.chatsModelInst.communities.activeCommunity.admin
draggableCategories: root.store.chatsModelInst.communities.activeCommunity.admin
chatList.model: root.store.chatsModelInst.communities.activeCommunity.chats
categoryList.model: chatsModel.communities.activeCommunity.categories
categoryList.model: root.store.chatsModelInst.communities.activeCommunity.categories
showCategoryActionButtons: chatsModel.communities.activeCommunity.admin
showPopupMenu: chatsModel.communities.activeCommunity.admin && chatsModel.communities.activeCommunity.canManageUsers
selectedChatId: chatsModel.channelView.activeChannel.id
showCategoryActionButtons: root.store.chatsModelInst.communities.activeCommunity.admin
showPopupMenu: root.store.chatsModelInst.communities.activeCommunity.admin && chatsModel.communities.activeCommunity.canManageUsers
selectedChatId: root.store.chatsModelInst.channelView.activeChannel.id
onChatItemSelected: chatsModel.channelView.setActiveChannel(id)
onChatItemUnmuted: chatsModel.channelView.unmuteChatItem(id)
onChatItemSelected: root.store.chatsModelInst.channelView.setActiveChannel(id)
onChatItemUnmuted: root.store.chatsModelInst.channelView.unmuteChatItem(id)
onChatItemReordered: function (categoryId, id, from, to) {
chatsModel.communities.reorderCommunityChannel(chatsModel.communities.activeCommunity.id, categoryId, id, to);
root.store.chatsModelInst.communities.reorderCommunityChannel(chatsModel.communities.activeCommunity.id, categoryId, id, to);
}
onChatListCategoryReordered: function (categoryId, from, to) {
chatsModel.communities.reorderCommunityCategories(chatsModel.communities.activeCommunity.id, categoryId, to);
root.store.chatsModelInst.communities.reorderCommunityCategories(chatsModel.communities.activeCommunity.id, categoryId, to);
}
onCategoryAddButtonClicked: openPopup(createChannelPopup, {
communityId: chatsModel.communities.activeCommunity.id,
communityId: root.store.chatsModelInst.communities.activeCommunity.id,
categoryId: id
})
@ -156,15 +156,15 @@ Item {
text: qsTrId("create-channel")
icon.name: "channel"
enabled: chatsModel.communities.activeCommunity.admin
onTriggered: openPopup(createChannelPopup, {communityId: chatsModel.communities.activeCommunity.id})
onTriggered: openPopup(createChannelPopup, {communityId: root.store.chatsModelInst.communities.activeCommunity.id})
}
StatusMenuItem {
//% "Create category"
text: qsTrId("create-category")
icon.name: "channel-category"
enabled: chatsModel.communities.activeCommunity.admin
onTriggered: openPopup(createCategoryPopup, {communityId: chatsModel.communities.activeCommunity.id})
enabled: root.store.chatsModelInst.communities.activeCommunity.admin
onTriggered: openPopup(createCategoryPopup, {communityId: root.store.chatsModelInst.communities.activeCommunity.id})
}
StatusMenuSeparator {}
@ -173,9 +173,9 @@ Item {
//% "Invite people"
text: qsTrId("invite-people")
icon.name: "share-ios"
enabled: chatsModel.communities.activeCommunity.canManageUsers
enabled: root.store.chatsModelInst.communities.activeCommunity.canManageUsers
onTriggered: openPopup(inviteFriendsToCommunityPopup, {
community: chatsModel.communities.activeCommunity
community: root.store.chatsModelInst.communities.activeCommunity
})
}
}
@ -185,17 +185,17 @@ Item {
property var categoryItem
openHandler: function (id) {
categoryItem = chatsModel.communities.activeCommunity.getCommunityCategoryItemById(id)
categoryItem = root.store.chatsModelInst.communities.activeCommunity.getCommunityCategoryItemById(id)
}
StatusMenuItem {
enabled: chatsModel.communities.activeCommunity.admin
enabled: root.store.chatsModelInst.communities.activeCommunity.admin
//% "Edit Category"
text: qsTrId("edit-category")
icon.name: "edit"
onTriggered: {
openPopup(createCategoryPopup, {
communityId: chatsModel.communities.activeCommunity.id,
communityId: root.store.chatsModelInst.communities.activeCommunity.id,
isEdit: true,
categoryId: categoryItem.id,
categoryName: categoryItem.name
@ -204,11 +204,11 @@ Item {
}
StatusMenuSeparator {
visible: chatsModel.communities.activeCommunity.admin
visible: root.store.chatsModelInst.communities.activeCommunity.admin
}
StatusMenuItem {
enabled: chatsModel.communities.activeCommunity.admin
enabled: root.store.chatsModelInst.communities.activeCommunity.admin
//% "Delete Category"
text: qsTrId("delete-category")
icon.name: "delete"
@ -227,29 +227,30 @@ Item {
}
chatListPopupMenu: ChatContextMenuView {
store: root.store
openHandler: function (id) {
chatItem = chatsModel.channelView.getChatItemById(id)
chatItem = root.store.chatsModelInst.channelView.getChatItemById(id)
}
}
}
Loader {
id: emptyViewAndSuggestionsLoader
active: chatsModel.communities.activeCommunity.admin && !appSettings.hiddenCommunityWelcomeBanners.includes(chatsModel.communities.activeCommunity.id)
active: root.store.chatsModelInst.communities.activeCommunity.admin && !appSettings.hiddenCommunityWelcomeBanners.includes(root.store.chatsModelInst.communities.activeCommunity.id)
width: parent.width
height: active ? item.height : 0
anchors.top: communityChatListAndCategories.bottom
anchors.topMargin: active ? Style.current.padding : 0
sourceComponent: Component {
CommunityWelcomeBannerPanel {
activeCommunity: rootStore.activeCommunity
activeCommunity: store.activeCommunity
}
}
}
Loader {
id: backUpBannerLoader
active: chatsModel.communities.activeCommunity.admin && !appSettings.hiddenCommunityBackUpBanners.includes(chatsModel.communities.activeCommunity.id)
active: root.store.chatsModelInst.communities.activeCommunity.admin && !appSettings.hiddenCommunityBackUpBanners.includes(root.store.chatsModelInst.communities.activeCommunity.id)
width: parent.width
height: active ? item.height : 0
anchors.top: emptyViewAndSuggestionsLoader.bottom
@ -310,7 +311,7 @@ Item {
close();
}
onConfirmButtonClicked: function(){
const error = chatsModel.communities.deleteCommunityCategory(chatsModel.communities.activeCommunity.id, categoryId)
const error = root.store.chatsModelInst.communities.deleteCommunityCategory(root.store.chatsModelInst.communities.activeCommunity.id, categoryId)
if (error) {
creatingError.text = error
return creatingError.open()

View File

@ -217,7 +217,8 @@ Item {
Connections {
target: chatsModel.messageView
enabled: !!root.store
target: enabled ? root.store.chatsModelInst.messageView : null
onMessageEdited: {
if(chatReply.item)
chatReply.item.messageEdited(editedMessageId, editedMessageContent)
@ -235,7 +236,7 @@ Item {
longReply: active && textFieldImplicitWidth > width
container: root.container
chatHorizontalPadding: root.chatHorizontalPadding
stickerData: chatsModel.messageView.messageList.getMessageData(replyMessageIndex, "sticker")
stickerData: !!root.store ? root.store.chatsModelInst.messageView.messageList.getMessageData(replyMessageIndex, "sticker") : null
active: responseTo !== "" && replyMessageIndex > -1 && !activityCenterMessage
// To-Do move to store later?
// isCurrentUser: root.messageStore.isCurrentUser
@ -290,7 +291,7 @@ Item {
}
}
ChatTimeView {
ChatTimePanel {
id: chatTime
visible: !isEdit && headerRepeatCondition
anchors.verticalCenter: chatName.verticalCenter
@ -370,7 +371,7 @@ Item {
StatusChatInput {
id: editTextInput
chatInputPlaceholder: qsTrId("type-a-message-")
chatType: chatsModel.channelView.activeChannel.chatType
chatType: root.store.chatsModelInst.channelView.activeChannel.chatType
isEdit: true
textInput.text: editMessageLoader.sourceText
onSendMessage: {
@ -406,11 +407,11 @@ Item {
text: qsTrId("save")
enabled: editTextInput.textInput.text.trim().length > 0
onClicked: {
let msg = chatsModel.plainText(Emoji.deparse(editTextInput.textInput.text))
let msg = root.store.chatsModelInst.plainText(Emoji.deparse(editTextInput.textInput.text))
if (msg.length > 0){
msg = chatInput.interpretMessage(msg)
isEdit = false
chatsModel.messageView.editMessage(messageId, contentType == Constants.editType ? replaces : messageId, msg);
root.store.chatsModelInst.messageView.editMessage(messageId, contentType == Constants.editType ? replaces : messageId, msg);
}
}
}
@ -431,6 +432,7 @@ Item {
ChatTextView {
id: chatText
store: root.store
messageStore: root.messageStore
readonly property int leftPadding: chatImage.anchors.leftMargin + chatImage.width + root.chatHorizontalPadding
visible: {
@ -538,6 +540,7 @@ Item {
sourceComponent: Component {
LinksMessageView {
store: root.store
linkUrls: root.linkUrls
container: root.container
isCurrentUser: root.isCurrentUser
@ -564,17 +567,8 @@ Item {
anchors.top: parent.top
anchors.topMargin: active ? (chatName.visible ? 4 : 6) : 0
sourceComponent: Component {
TransactionBubblePanel {
balanceView: root.store.walletModelInst.balanceView
focusedAccount: root.store.walletModelInst.accountsView.focusedAccount
activeChannelName: root.store.chatsModelInst.channelView.activeChannel.name
activeChannelIdenticon: root.store.chatsModelInst.channelView.activeChannel.identicon
onGetGasPrice: {
root.store.walletModelInst.gasView.getGasPrice();
}
onSendTransactionClicked: {
root.store.walletModelInst.accountsView.setFocusedAccountByAddress(fromAddress);
}
TransactionBubbleView {
store: root.store
}
}
}
@ -656,7 +650,7 @@ Item {
messageContextMenu.setXPosition = function() { return (messageContextMenu.parent.x + 4)}
messageContextMenu.setYPosition = function() { return (-messageContextMenu.height - 4)}
}
onToggleReaction: chatsModel.toggleReaction(messageId, emojiID)
onToggleReaction: root.store.chatsModelInst.toggleReaction(messageId, emojiID)
onSetMessageActive: {
root.messageStore.setMessageActive(messageId, active);;

View File

@ -17,10 +17,11 @@ import StatusQ.Components 0.1
import StatusQ.Popups 0.1
Item {
id: contactsColumn
id: root
width: 304
height: parent.height
property var store
property int chatGroupsListViewCount: channelList.chatListItems.count
signal openProfileClicked()
@ -184,7 +185,7 @@ Item {
StatusContactRequestsIndicatorListItem {
id: contactRequests
property int nbRequests: profileModel.contacts.contactRequests.count
property int nbRequests: root.store.profileModelInst.contacts.contactRequests.count
anchors.top: searchInputWrapper.bottom
anchors.topMargin: visible ? Style.current.padding : 0
@ -207,7 +208,7 @@ Item {
height: (contentHeight < (parent.height - contactRequests.height - Style.current.padding)) ? contentHeight : (parent.height - contactRequests.height - Style.current.padding)
anchors.top: contactRequests.bottom
anchors.topMargin: Style.current.padding
anchors.bottom: contactsColumn.bottom
anchors.bottom: root.bottom
contentHeight: channelList.childrenRect.height + emptyViewAndSuggestions.childrenRect.height
anchors.horizontalCenter: parent.horizontalCenter
@ -232,12 +233,12 @@ Item {
}
Connections {
target: profileModel.contacts.list
target: root.store.profileModelInst.contacts.list
onContactChanged: {
for (var i = 0; i < channelList.chatListItems.count; i++) {
let chatItem = !!channelList.statusChatListItems.model.itemAt(i) ?
channelList.statusChatListItems.model.itemAt(i) : null
if (!!chatItem) {
if (!!channelList.statusChatListItems) {
let chatItem = !!channelList.statusChatListItems.model ?
channelList.statusChatListItems.model.itemAt(i) : null
if (chatItem.chatId === pubkey) {
let profileImage = appMain.getProfileImage(pubkey)
if (!!profileImage) {
@ -251,15 +252,16 @@ Item {
}
}
chatListItems.model: chatsModel.channelView.chats
selectedChatId: chatsModel.channelView.activeChannel.id
chatListItems.model: root.store.chatsModelInst.channelView.chats
selectedChatId: root.store.chatsModelInst.channelView.activeChannel.id
onChatItemSelected: chatsModel.channelView.setActiveChannel(id)
onChatItemUnmuted: chatsModel.channelView.unmuteChatItem(id)
onChatItemSelected: root.store.chatsModelInst.channelView.setActiveChannel(id)
onChatItemUnmuted: root.store.chatsModelInst.channelView.unmuteChatItem(id)
popupMenu: ChatContextMenuView {
store: root.store
openHandler: function (id) {
chatItem = chatsModel.channelView.getChatItemById(id)
chatItem = root.store.chatsModelInst.channelView.getChatItemById(id)
}
}
}
@ -270,7 +272,7 @@ Item {
width: parent.width
anchors.top: channelList.bottom
anchors.topMargin: Style.current.padding
onSuggestedMessageClicked: chatsModel.channelView.joinPublicChat(channel)
onSuggestedMessageClicked: root.store.chatsModelInst.channelView.joinPublicChat(channel)
}
}
@ -299,7 +301,7 @@ Item {
destroy()
}
onProfileClicked: {
contactsColumn.openProfileClicked();
root.openProfileClicked();
}
}
}
@ -353,7 +355,7 @@ Item {
}
Connections {
target: chatsModel.communities
target: root.store.chatsModelInst.communities
onImportingCommunityStateChanged: {
if (state !== Constants.communityImported &&
state !== Constants.communityImportingInProgress &&

View File

@ -15,11 +15,11 @@ import "../panels"
Column {
id: root
property string linkUrls: ""
property var store
property var container
property string linkUrls: ""
property bool isCurrentUser: false
property bool isImageLink: false
property var rootStore
readonly property string uuid: Utils.uuid()
spacing: Style.current.halfPadding
@ -66,7 +66,7 @@ Column {
Connections {
id: linkFetchConnections
enabled: false
target: chatsModel
target: root.store.chatsModelInst
onLinkPreviewDataWasReceived: {
let response
try {
@ -102,7 +102,7 @@ Column {
Connections {
id: linkCommunityFetchConnections
enabled: false
target: chatsModel.communities
target: root.store.chatsModelInst.communities
onCommunityAdded: {
if (communityId !== linkData.communityId) {
return
@ -173,7 +173,7 @@ Column {
}
linkFetchConnections.enabled = true
return chatsModel.getLinkPreviewData(link, root.uuid)
return root.store.chatsModelInst.getLinkPreviewData(link, root.uuid)
}
// setting the height to 0 allows the "enable link" dialog to
// disappear correctly when appSettings.neverAskAboutUnfurlingAgain
@ -212,7 +212,7 @@ Column {
Component {
id: invitationBubble
InvitationBubbleView {
store: root.rootStore
store: root.store
communityId: linkData.communityId
isLink: true
anchors.left: parent.left

View File

@ -11,12 +11,17 @@ import "../panels"
import "../views"
import "../controls"
//TODO RE-WRITE THIS COMPONENT
Column {
id: root
width: parent.width
anchors.right: !isCurrentUser ? undefined : parent.right
z: (typeof chatLogView === "undefined") ? 1 : (chatLogView.count - index)
property var rootStore
property var messageStore
property var chatsModel: !!root.rootStore ? root.rootStore.chatsModelInst : null
//////////////////////////////////////
//TODO REMOVE
property string fromAuthor: "0x0011223344556677889910"
@ -74,8 +79,8 @@ Column {
property string authorCurrentMsg: "authorCurrentMsg"
property string authorPrevMsg: "authorPrevMsg"
property string prevMsgTimestamp: chatsModel.messageView.messageList.getMessageData(prevMessageIndex, "timestamp")
property string nextMsgTimestamp: chatsModel.messageView.messageList.getMessageData(nextMessageIndex, "timestamp")
property string prevMsgTimestamp: !!root.chatsModel ? root.chatsModel.messageView.messageList.getMessageData(prevMessageIndex, "timestamp") : ""
property string nextMsgTimestamp: !!root.chatsModel ? root.chatsModel.messageView.messageList.getMessageData(nextMessageIndex, "timestamp"): ""
property bool shouldRepeatHeader: ((parseInt(timestamp, 10) - parseInt(prevMsgTimestamp, 10)) / 60 / 1000) > Constants.repeatHeaderInterval
@ -92,15 +97,15 @@ Column {
property bool isStatusUpdate: false
property int statusAgeEpoch: 0
property int replyMessageIndex: chatsModel.messageView.messageList.getMessageIndex(responseTo);
property string repliedMessageAuthor: replyMessageIndex > -1 ? chatsModel.messageView.messageList.getMessageData(replyMessageIndex, "userName") : "";
property string repliedMessageAuthorPubkey: replyMessageIndex > -1 ? chatsModel.messageView.messageList.getMessageData(replyMessageIndex, "publicKey") : "";
property int replyMessageIndex: !!root.chatsModel ? root.chatsModel.messageView.messageList.getMessageIndex(responseTo) : -1
property string repliedMessageAuthor: replyMessageIndex > -1 ? !!root.chatsModel ? root.chatsModel.messageView.messageList.getMessageData(replyMessageIndex, "userName") : "" : "";
property string repliedMessageAuthorPubkey: replyMessageIndex > -1 ? root.chatsModel.messageView.messageList.getMessageData(replyMessageIndex, "publicKey") : "";
property bool repliedMessageAuthorIsCurrentUser: replyMessageIndex > -1 ? repliedMessageAuthorPubkey === profileModel.profile.pubKey : "";
property bool repliedMessageIsEdited: replyMessageIndex > -1 ? chatsModel.messageView.messageList.getMessageData(replyMessageIndex, "isEdited") === "true" : false;
property string repliedMessageContent: replyMessageIndex > -1 ? chatsModel.messageView.messageList.getMessageData(replyMessageIndex, "message") : "";
property int repliedMessageType: replyMessageIndex > -1 ? parseInt(chatsModel.messageView.messageList.getMessageData(replyMessageIndex, "contentType")) : 0;
property string repliedMessageImage: replyMessageIndex > -1 ? chatsModel.messageView.messageList.getMessageData(replyMessageIndex, "image") : "";
property string repliedMessageUserIdenticon: replyMessageIndex > -1 ? chatsModel.messageView.messageList.getMessageData(replyMessageIndex, "identicon") : "";
property bool repliedMessageIsEdited: replyMessageIndex > -1 ? !!root.chatsModel ? root.chatsModel.messageView.messageList.getMessageData(replyMessageIndex, "isEdited") === "true" : false : false;
property string repliedMessageContent: replyMessageIndex > -1 ? !!root.chatsModel ? root.chatsModel.messageView.messageList.getMessageData(replyMessageIndex, "message") : "" : "";
property int repliedMessageType: replyMessageIndex > -1 ? !!root.chatsModel ? parseInt(root.chatsModel.messageView.messageList.getMessageData(replyMessageIndex, "contentType")) : 0 : 0;
property string repliedMessageImage: replyMessageIndex > -1 ? !!root.chatsModel ? root.chatsModel.messageView.messageList.getMessageData(replyMessageIndex, "image") : "" : "";
property string repliedMessageUserIdenticon: replyMessageIndex > -1 ? !!root.chatsModel ? root.chatsModel.messageView.messageList.getMessageData(replyMessageIndex, "identicon") : "" : "";
property string repliedMessageUserImage: replyMessageIndex > -1 ? appMain.getProfileImage(repliedMessageAuthorPubkey, repliedMessageAuthorIsCurrentUser , false) || "" : "";
property var imageClick: function () {}
@ -134,8 +139,8 @@ Column {
}
}
byEmoji[reaction.emojiId].count++;
byEmoji[reaction.emojiId].fromAccounts.push(chatsModel.userNameOrAlias(reaction.from));
if (!byEmoji[reaction.emojiId].currentUserReacted && reaction.from === profileModel.profile.pubKey) {
byEmoji[reaction.emojiId].fromAccounts.push(root.chatsModel.userNameOrAlias(reaction.from));
if (!byEmoji[reaction.emojiId].currentUserReacted && reaction.from === root.rootStore.profileModelInst.profile.pubKey) {
byEmoji[reaction.emojiId].currentUserReacted = true
}
@ -193,10 +198,6 @@ Column {
}
/////////////////////////////////////////////
property var rootStore
property var messageStore
Connections {
enabled: (!placeholderMessage && !!root.rootStore)
target: !!root.rootStore ? root.rootStore.profileModelInst.contacts.list : null
@ -217,7 +218,7 @@ Column {
Connections {
enabled: !!root.rootStore
target: !!root.rootStore ? root.rootStore.chatsModelInst.messageView : null
target: !!root.rootStore ? root.chatsModel.messageView : null
onHideMessage: {
// This hack is used because message_list deleteMessage sometimes does not remove the messages (there might be an issue with the delegate model)
if(mId === messageId){
@ -252,7 +253,7 @@ Column {
id: gapComponent
GapComponent {
onClicked: {
rootStore.chatsModelInst.messageView.fillGaps(messageStore.messageId);
root.chatsModel.messageView.fillGaps(messageStore.messageId);
root.visible = false;
root.height = 0;
}
@ -265,10 +266,10 @@ Column {
// nextMessageIndex: root.messageStore.nextMessageIndex
// nextMsgTimestamp: root.messageStore.nextMsgTimestamp
onClicked: {
rootStore.chatsModelInst.messageView.hideLoadingIndicator();
root.chatsModel.messageView.hideLoadingIndicator();
}
onTimerTriggered: {
rootStore.chatsModelInst.requestMoreMessages(Constants.fetchRangeLast24Hours);
root.chatsModel.requestMoreMessages(Constants.fetchRangeLast24Hours);
}
}
}
@ -276,8 +277,9 @@ Column {
Component {
id: channelIdentifierComponent
ChannelIdentifierView {
authorCurrentMsg: root.authorCurrentMsg
store: root.rootStore
profileImage: profileImageSource
authorCurrentMsg: root.authorCurrentMsg
}
}
@ -319,14 +321,17 @@ Column {
isCurrentUser: root.isCurrentUser
contentType: root.contentType
container: root
store: root.rootStore
messageStore: root.messageStore
}
}
Component {
id: statusUpdateComponent
StatusUpdatePanel {
StatusUpdateView {
statusAgeEpoch: root.statusAgeEpoch
container: root
store: root.rootStore
messageContextMenu: root.messageContextMenu
onAddEmoji: {
root.clickMessage(isProfileClick, isSticker, isImage , image, emojiOnly, hideEmojiPicker);
@ -358,6 +363,7 @@ Column {
showEdit: root.showEdit
container: root
messageContextMenu: root.messageContextMenu
store: root.rootStore
messageStore: root.messageStore
onAddEmoji: {
root.clickMessage(isProfileClick, isSticker, isImage , image, emojiOnly, hideEmojiPicker);

View File

@ -153,7 +153,7 @@ Item {
anchors.rightMargin: chatBox.chatHorizontalPadding
container: root.container
chatHorizontalPadding: chatBox.chatHorizontalPadding
stickerData: chatsModel.messageView.messageList.getMessageData(replyMessageIndex, "sticker")
stickerData: root.store.chatsModelInst.messageView.messageList.getMessageData(replyMessageIndex, "sticker")
active: responseTo !== "" && replyMessageIndex > -1 && !activityCenterMessage
// To-Do move to store later?
// isCurrentUser: root.messageStore.isCurrentUser
@ -175,7 +175,7 @@ Item {
Connections {
target: chatsModel.messageView
target: root.store.chatsModelInst.messageView
onMessageEdited: {
if(chatReply.item)
chatReply.item.messageEdited(editedMessageId, editedMessageContent)
@ -191,6 +191,7 @@ Item {
anchors.leftMargin: chatBox.chatHorizontalPadding
anchors.right: chatBox.longChatText ? parent.right : undefined
anchors.rightMargin: chatBox.longChatText ? chatBox.chatHorizontalPadding : 0
store: root.store
messageStore: root.store.messageStore
textField.color: !root.isCurrentUser ? Style.current.textColor : Style.current.currentUserTextColor
Connections {
@ -288,17 +289,8 @@ Item {
anchors.right: isCurrentUser ? parent.right : undefined
anchors.rightMargin: Style.current.padding
sourceComponent: Component {
TransactionBubblePanel {
balanceView: root.store.walletModelInst.balanceView
focusedAccount: root.store.walletModelInst.accountsView.focusedAccount
activeChannelName: root.store.chatsModelInst.channelView.activeChannel.name
activeChannelIdenticon: root.store.chatsModelInst.channelView.activeChannel.identicon
onGetGasPrice: {
root.store.walletModelInst.gasView.getGasPrice();
}
onSendTransactionClicked: {
root.store.walletModelInst.accountsView.setFocusedAccountByAddress(fromAddress);
}
TransactionBubbleView {
store: root.store
}
}
}
@ -317,7 +309,7 @@ Item {
anchors.rightMargin: 6
}
ChatTimeView {
ChatTimePanel {
id: chatTime
visible: root.messageStore.isMessage && !emojiReactionLoader.active
anchors.top: isImage ? undefined : (linksLoader.active ? linksLoader.bottom : chatBox.bottom)
@ -361,6 +353,7 @@ Item {
sourceComponent: Component {
LinksMessageView {
store: root.store
linkUrls: root.linkUrls
container: root.container
isCurrentUser: root.isCurrentUser
@ -387,7 +380,7 @@ Item {
onSetMessageActive: {
root.store.messageStore.setMessageActive(messageId, active);;
}
onToggleReaction: chatsModel.toggleReaction(messageId, emojiID)
onToggleReaction: root.store.chatsModelInst.toggleReaction(messageId, emojiID)
}
}
}

View File

@ -6,15 +6,14 @@ import "../../../../shared/status"
import utils 1.0
import "../panels"
import "../controls"
//TODO remove this or make view
import "../views"
import StatusQ.Controls 0.1
MouseArea {
id: root
property var store
property bool hovered: containsMouse
property var container
property int statusAgeEpoch: 0
@ -93,7 +92,7 @@ MouseArea {
}
}
ChatTimeView {
ChatTimePanel {
id: chatTime
// statusAgeEpoch is used to trigger Qt property update
// since the returned string will be the same in 99% cases, this should not trigger ChatTime re-rendering
@ -113,6 +112,7 @@ MouseArea {
anchors.leftMargin: Style.current.halfPadding
anchors.right: parent.right
anchors.rightMargin: Style.current.padding
store: root.store
}
Loader {

View File

@ -12,6 +12,7 @@ Item {
width: rectangleBubble.width
height: rectangleBubble.height
property var store
property var commandParametersObject: {
try {
return JSON.parse(commandParameters)
@ -31,12 +32,7 @@ Item {
}
}
}
property var focusedAccount
property string activeChannelName
property string activeChannelIdenticon
property var balanceView
signal getGasPrice()
signal sendTransactionClicked(string fromAddress)
property var token: JSON.parse(commandParametersObject.contract) // TODO: handle {}
property string tokenAmount: commandParametersObject.value
property string tokenSymbol: token.symbol || ""
@ -44,8 +40,8 @@ Item {
if (!tokenAmount || !token.symbol) {
return "0"
}
var defaultFiatSymbol = root.balanceView.defaultCurrency
return root.balanceView.getFiatValue(tokenAmount, token.symbol, defaultFiatSymbol) + " " + defaultFiatSymbol.toUpperCase()
var defaultFiatSymbol = root.store.walletModelInst.balanceView.defaultCurrency
return root.store.walletModelInst.balanceView.getFiatValue(tokenAmount, token.symbol, defaultFiatSymbol) + " " + defaultFiatSymbol.toUpperCase()
}
property int state: commandParametersObject.commandState
@ -185,6 +181,7 @@ Item {
AcceptTransactionView {
state: root.state
store: root.store
}
}
@ -193,7 +190,7 @@ Item {
SendTransactionButton {
// outgoing: root.outgoing
acc: root.focusedAccount
acc: root.store.walletModelInst.accountsView.focusedAccount
selectedAsset: token
selectedAmount: tokenAmount
selectedFiatAmount: fiatValue
@ -201,16 +198,16 @@ Item {
selectedRecipient: {
return {
address: commandParametersObject.address,
identicon: root.activeChannelIdenticon,
name: root.activeChannelName,
identicon: root.store.chatsModelInst.channelView.activeChannel.identicon,
name: root.store.chatsModelInst.channelView.activeChannel.name,
type: RecipientSelector.Type.Contact
}
}
onSignModalOpened: {
root.getGasPrice();
root.store.walletModelInst.gasView.getGasPrice();
}
onSendTransaction: {
root.sendTransactionClicked(address);
root.store.walletModelInst.accountsView.setFocusedAccountByAddress(fromAddress);
}
}
}

View File

@ -14,6 +14,7 @@ import "../../../../shared/panels"
//TODO remove these dependencies in imports
import "../../Chat/views"
import "../../Chat/panels"
import "../../Chat/controls"
Item {
@ -325,13 +326,14 @@ Item {
anchors.leftMargin: chatBox.chatHorizontalPadding
width: parent.width
anchors.right: parent.right
store: root.store
messageStore: root.messageStore
}
RectangleCorner {}
}
ChatTimeView {
ChatTimePanel {
id: chatTime
anchors.top: chatBox.bottom
anchors.topMargin: 4
@ -339,6 +341,7 @@ Item {
anchors.right: chatBox.right
anchors.rightMargin: Style.current.padding
//timestamp: root.timestamp
visible: root.messageStore.isMessage
}
StatusBaseText {