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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -5,33 +5,33 @@ import "../../../../shared/panels"
import utils 1.0 import utils 1.0
Column { Column {
property string authorCurrentMsg: "authorCurrentMsg" id: root
property string profileImage
id: channelIdentifier
spacing: Style.current.padding spacing: Style.current.padding
visible: authorCurrentMsg === "" visible: authorCurrentMsg === ""
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
topPadding: visible ? Style.current.bigPadding : 0 topPadding: visible ? Style.current.bigPadding : 0
bottomPadding: visible? 50 : 0 bottomPadding: visible? 50 : 0
property var store
property string authorCurrentMsg: "authorCurrentMsg"
property string profileImage
Rectangle { Rectangle {
id: circleId id: circleId
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
width: 120 width: 120
height: 120 height: 120
radius: 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 border.color: Style.current.border
color: { color: {
if (chatsModel.channelView.activeChannel.chatType === Constants.chatTypeOneToOne) { if (root.store.chatsModelInst.channelView.activeChannel.chatType === Constants.chatTypeOneToOne) {
return Style.current.transparent return Style.current.transparent
} }
if (chatsModel.channelView.activeChannel.color) { if (root.store.chatsModelInst.channelView.activeChannel.color) {
return chatsModel.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) { if (!color) {
return Style.current.orange return Style.current.orange
} }
@ -39,19 +39,21 @@ Column {
} }
RoundedImage { RoundedImage {
visible: chatsModel.channelView.activeChannel.chatType === Constants.chatTypeOneToOne visible: root.store.chatsModelInst.channelView.activeChannel.chatType === Constants.chatTypeOneToOne
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
width: 120 width: 120
height: 120 height: 120
source: channelIdentifier.profileImage || chatsModel.channelView.activeChannel.identicon source: root.profileImage || root.store.chatsModelInst.channelView.activeChannel.identicon
smooth: false smooth: false
antialiasing: true antialiasing: true
} }
StyledText { StyledText {
visible: chatsModel.channelView.activeChannel.chatType !== Constants.chatTypeOneToOne visible: root.store.chatsModelInst.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()) 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 opacity: 0.7
font.weight: Font.Bold font.weight: Font.Bold
font.pixelSize: 51 font.pixelSize: 51
@ -65,10 +67,10 @@ Column {
id: channelName id: channelName
wrapMode: Text.Wrap wrapMode: Text.Wrap
text: { text: {
switch(chatsModel.channelView.activeChannel.chatType) { switch(root.store.chatsModelInst.channelView.activeChannel.chatType) {
case Constants.chatTypePublic: return "#" + chatsModel.channelView.activeChannel.name; case Constants.chatTypePublic: return "#" + root.store.chatsModelInst.channelView.activeChannel.name;
case Constants.chatTypeOneToOne: return Utils.removeStatusEns(chatsModel.userNameOrAlias(chatsModel.channelView.activeChannel.id)) case Constants.chatTypeOneToOne: return Utils.removeStatusEns(root.store.chatsModelInst.userNameOrAlias(chatsModel.channelView.activeChannel.id))
default: return chatsModel.channelView.activeChannel.name default: return root.store.chatsModelInst.channelView.activeChannel.name
} }
} }
font.weight: Font.Bold font.weight: Font.Bold
@ -83,9 +85,9 @@ Column {
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
width: 310 width: 310
text: { 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!" //% "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>" //% "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) 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 ""; default: return "";
@ -98,7 +100,8 @@ Column {
} }
Item { 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 anchors.horizontalCenter: parent.horizontalCenter
width: visible ? joinChat.width : 0 width: visible ? joinChat.width : 0
height: visible ? 100 : 0 height: visible ? 100 : 0
@ -116,7 +119,7 @@ Column {
cursorShape: Qt.PointingHandCursor cursorShape: Qt.PointingHandCursor
anchors.fill: parent anchors.fill: parent
onClicked: { onClicked: {
chatsModel.groups.join() root.store.chatsModelInst.groups.join()
} }
} }
} }
@ -133,7 +136,7 @@ Column {
cursorShape: Qt.PointingHandCursor cursorShape: Qt.PointingHandCursor
anchors.fill: parent anchors.fill: parent
onClicked: { onClicked: {
chatsModel.channelView.leaveActiveChat() root.store.chatsModelInst.channelView.leaveActiveChat()
} }
} }
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -153,7 +153,7 @@ Item {
anchors.rightMargin: chatBox.chatHorizontalPadding anchors.rightMargin: chatBox.chatHorizontalPadding
container: root.container container: root.container
chatHorizontalPadding: chatBox.chatHorizontalPadding chatHorizontalPadding: chatBox.chatHorizontalPadding
stickerData: chatsModel.messageView.messageList.getMessageData(replyMessageIndex, "sticker") stickerData: root.store.chatsModelInst.messageView.messageList.getMessageData(replyMessageIndex, "sticker")
active: responseTo !== "" && replyMessageIndex > -1 && !activityCenterMessage active: responseTo !== "" && replyMessageIndex > -1 && !activityCenterMessage
// To-Do move to store later? // To-Do move to store later?
// isCurrentUser: root.messageStore.isCurrentUser // isCurrentUser: root.messageStore.isCurrentUser
@ -175,7 +175,7 @@ Item {
Connections { Connections {
target: chatsModel.messageView target: root.store.chatsModelInst.messageView
onMessageEdited: { onMessageEdited: {
if(chatReply.item) if(chatReply.item)
chatReply.item.messageEdited(editedMessageId, editedMessageContent) chatReply.item.messageEdited(editedMessageId, editedMessageContent)
@ -191,6 +191,7 @@ Item {
anchors.leftMargin: chatBox.chatHorizontalPadding anchors.leftMargin: chatBox.chatHorizontalPadding
anchors.right: chatBox.longChatText ? parent.right : undefined anchors.right: chatBox.longChatText ? parent.right : undefined
anchors.rightMargin: chatBox.longChatText ? chatBox.chatHorizontalPadding : 0 anchors.rightMargin: chatBox.longChatText ? chatBox.chatHorizontalPadding : 0
store: root.store
messageStore: root.store.messageStore messageStore: root.store.messageStore
textField.color: !root.isCurrentUser ? Style.current.textColor : Style.current.currentUserTextColor textField.color: !root.isCurrentUser ? Style.current.textColor : Style.current.currentUserTextColor
Connections { Connections {
@ -288,17 +289,8 @@ Item {
anchors.right: isCurrentUser ? parent.right : undefined anchors.right: isCurrentUser ? parent.right : undefined
anchors.rightMargin: Style.current.padding anchors.rightMargin: Style.current.padding
sourceComponent: Component { sourceComponent: Component {
TransactionBubblePanel { TransactionBubbleView {
balanceView: root.store.walletModelInst.balanceView store: root.store
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);
}
} }
} }
} }
@ -317,7 +309,7 @@ Item {
anchors.rightMargin: 6 anchors.rightMargin: 6
} }
ChatTimeView { ChatTimePanel {
id: chatTime id: chatTime
visible: root.messageStore.isMessage && !emojiReactionLoader.active visible: root.messageStore.isMessage && !emojiReactionLoader.active
anchors.top: isImage ? undefined : (linksLoader.active ? linksLoader.bottom : chatBox.bottom) anchors.top: isImage ? undefined : (linksLoader.active ? linksLoader.bottom : chatBox.bottom)
@ -361,6 +353,7 @@ Item {
sourceComponent: Component { sourceComponent: Component {
LinksMessageView { LinksMessageView {
store: root.store
linkUrls: root.linkUrls linkUrls: root.linkUrls
container: root.container container: root.container
isCurrentUser: root.isCurrentUser isCurrentUser: root.isCurrentUser
@ -387,7 +380,7 @@ Item {
onSetMessageActive: { onSetMessageActive: {
root.store.messageStore.setMessageActive(messageId, active);; 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 utils 1.0
import "../panels"
import "../controls" import "../controls"
//TODO remove this or make view
import "../views"
import StatusQ.Controls 0.1 import StatusQ.Controls 0.1
MouseArea { MouseArea {
id: root id: root
property var store
property bool hovered: containsMouse property bool hovered: containsMouse
property var container property var container
property int statusAgeEpoch: 0 property int statusAgeEpoch: 0
@ -93,7 +92,7 @@ MouseArea {
} }
} }
ChatTimeView { ChatTimePanel {
id: chatTime id: chatTime
// statusAgeEpoch is used to trigger Qt property update // 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 // 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.leftMargin: Style.current.halfPadding
anchors.right: parent.right anchors.right: parent.right
anchors.rightMargin: Style.current.padding anchors.rightMargin: Style.current.padding
store: root.store
} }
Loader { Loader {

View File

@ -12,6 +12,7 @@ Item {
width: rectangleBubble.width width: rectangleBubble.width
height: rectangleBubble.height height: rectangleBubble.height
property var store
property var commandParametersObject: { property var commandParametersObject: {
try { try {
return JSON.parse(commandParameters) 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 var token: JSON.parse(commandParametersObject.contract) // TODO: handle {}
property string tokenAmount: commandParametersObject.value property string tokenAmount: commandParametersObject.value
property string tokenSymbol: token.symbol || "" property string tokenSymbol: token.symbol || ""
@ -44,8 +40,8 @@ Item {
if (!tokenAmount || !token.symbol) { if (!tokenAmount || !token.symbol) {
return "0" return "0"
} }
var defaultFiatSymbol = root.balanceView.defaultCurrency var defaultFiatSymbol = root.store.walletModelInst.balanceView.defaultCurrency
return root.balanceView.getFiatValue(tokenAmount, token.symbol, defaultFiatSymbol) + " " + defaultFiatSymbol.toUpperCase() return root.store.walletModelInst.balanceView.getFiatValue(tokenAmount, token.symbol, defaultFiatSymbol) + " " + defaultFiatSymbol.toUpperCase()
} }
property int state: commandParametersObject.commandState property int state: commandParametersObject.commandState
@ -185,6 +181,7 @@ Item {
AcceptTransactionView { AcceptTransactionView {
state: root.state state: root.state
store: root.store
} }
} }
@ -193,7 +190,7 @@ Item {
SendTransactionButton { SendTransactionButton {
// outgoing: root.outgoing // outgoing: root.outgoing
acc: root.focusedAccount acc: root.store.walletModelInst.accountsView.focusedAccount
selectedAsset: token selectedAsset: token
selectedAmount: tokenAmount selectedAmount: tokenAmount
selectedFiatAmount: fiatValue selectedFiatAmount: fiatValue
@ -201,16 +198,16 @@ Item {
selectedRecipient: { selectedRecipient: {
return { return {
address: commandParametersObject.address, address: commandParametersObject.address,
identicon: root.activeChannelIdenticon, identicon: root.store.chatsModelInst.channelView.activeChannel.identicon,
name: root.activeChannelName, name: root.store.chatsModelInst.channelView.activeChannel.name,
type: RecipientSelector.Type.Contact type: RecipientSelector.Type.Contact
} }
} }
onSignModalOpened: { onSignModalOpened: {
root.getGasPrice(); root.store.walletModelInst.gasView.getGasPrice();
} }
onSendTransaction: { 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 //TODO remove these dependencies in imports
import "../../Chat/views" import "../../Chat/views"
import "../../Chat/panels"
import "../../Chat/controls" import "../../Chat/controls"
Item { Item {
@ -325,13 +326,14 @@ Item {
anchors.leftMargin: chatBox.chatHorizontalPadding anchors.leftMargin: chatBox.chatHorizontalPadding
width: parent.width width: parent.width
anchors.right: parent.right anchors.right: parent.right
store: root.store
messageStore: root.messageStore messageStore: root.messageStore
} }
RectangleCorner {} RectangleCorner {}
} }
ChatTimeView { ChatTimePanel {
id: chatTime id: chatTime
anchors.top: chatBox.bottom anchors.top: chatBox.bottom
anchors.topMargin: 4 anchors.topMargin: 4
@ -339,6 +341,7 @@ Item {
anchors.right: chatBox.right anchors.right: chatBox.right
anchors.rightMargin: Style.current.padding anchors.rightMargin: Style.current.padding
//timestamp: root.timestamp //timestamp: root.timestamp
visible: root.messageStore.isMessage
} }
StatusBaseText { StatusBaseText {