diff --git a/src/app/modules/main/chat_section/chat_content/controller.nim b/src/app/modules/main/chat_section/chat_content/controller.nim index 2c3f110f5f..2ad143ea79 100644 --- a/src/app/modules/main/chat_section/chat_content/controller.nim +++ b/src/app/modules/main/chat_section/chat_content/controller.nim @@ -125,7 +125,7 @@ proc init*(self: Controller) = self.delegate.onChatRenamed(args.newName) self.events.on(SIGNAL_CHAT_UPDATE) do(e: Args): - var args = ChatUpdateArgsNew(e) + var args = ChatUpdateArgs(e) for chat in args.chats: if self.chatId == chat.id: self.delegate.onChatEdited(chat) diff --git a/src/app/modules/main/chat_section/chat_content/users/controller.nim b/src/app/modules/main/chat_section/chat_content/users/controller.nim index 6985b58771..a51dc70a03 100644 --- a/src/app/modules/main/chat_section/chat_content/users/controller.nim +++ b/src/app/modules/main/chat_section/chat_content/users/controller.nim @@ -113,7 +113,7 @@ proc init*(self: Controller) = self.delegate.onChatMembersAdded(args.ids) self.events.on(SIGNAL_CHAT_UPDATE) do(e: Args): - var args = ChatUpdateArgsNew(e) + var args = ChatUpdateArgs(e) for chat in args.chats: if (chat.id == self.chatId): self.delegate.onChatUpdated(chat) diff --git a/src/app/modules/main/chat_section/controller.nim b/src/app/modules/main/chat_section/controller.nim index 32c9870a79..a48247d574 100644 --- a/src/app/modules/main/chat_section/controller.nim +++ b/src/app/modules/main/chat_section/controller.nim @@ -105,13 +105,20 @@ proc init*(self: Controller) = self.delegate.onContactUnblocked(args.contactId) self.events.on(SIGNAL_CHAT_UPDATE) do(e: Args): - var args = ChatUpdateArgsNew(e) + var args = ChatUpdateArgs(e) for chat in args.chats: let belongsToCommunity = chat.communityId.len > 0 self.delegate.addChatIfDontExist(chat, belongsToCommunity, self.events, self.settingsService, self.contactService, self.chatService, self.communityService, self.messageService, self.gifService, self.mailserversService, setChatAsActive = false) + self.events.on(SIGNAL_CHAT_CREATED) do(e: Args): + var args = CreatedChatArgs(e) + let belongsToCommunity = args.chat.communityId.len > 0 + self.delegate.addChatIfDontExist(args.chat, belongsToCommunity, self.events, self.settingsService, + self.contactService, self.chatService, self.communityService, self.messageService, self.gifService, + self.mailserversService, setChatAsActive = true) + if (self.isCommunitySection): self.events.on(SIGNAL_COMMUNITY_CHANNEL_CREATED) do(e:Args): let args = CommunityChatArgs(e) diff --git a/src/app/modules/main/chat_section/module.nim b/src/app/modules/main/chat_section/module.nim index 62b2ad4c84..f3af5cb1c9 100644 --- a/src/app/modules/main/chat_section/module.nim +++ b/src/app/modules/main/chat_section/module.nim @@ -796,16 +796,14 @@ method addChatIfDontExist*(self: Module, gifService: gif_service.Service, mailserversService: mailservers_service.Service, setChatAsActive: bool = true) = - let sectionId = self.controller.getMySectionId() if(belongsToCommunity and sectionId != chat.communityId or not belongsToCommunity and sectionId != singletonInstance.userProfile.getPubKey()): return if self.doesCatOrChatExist(chat.id): - if chat.chatType != ChatType.OneToOne: + if(chat.chatType != ChatType.OneToOne): self.onChatRenamed(chat.id, chat.name) return - self.addNewChat(chat, belongsToCommunity, events, settingsService, contactService, chatService, communityService, messageService, gifService, mailserversService, setChatAsActive) diff --git a/src/app/modules/main/profile_section/notifications/controller.nim b/src/app/modules/main/profile_section/notifications/controller.nim index 2e7b9ba2f0..82542c241d 100644 --- a/src/app/modules/main/profile_section/notifications/controller.nim +++ b/src/app/modules/main/profile_section/notifications/controller.nim @@ -75,7 +75,7 @@ proc init*(self: Controller) = self.delegate.removeItemWithId(args.chatId) self.events.on(SIGNAL_CHAT_UPDATE) do(e: Args): - var args = ChatUpdateArgsNew(e) + var args = ChatUpdateArgs(e) for chat in args.chats: let belongsToCommunity = chat.communityId.len > 0 self.delegate.addChat(chat) diff --git a/src/app_service/service/activity_center/service.nim b/src/app_service/service/activity_center/service.nim index f9467eb0a8..e4cf3fd4dc 100644 --- a/src/app_service/service/activity_center/service.nim +++ b/src/app_service/service/activity_center/service.nim @@ -186,7 +186,7 @@ QtObject: let (chats, messages) = self.chatService.parseChatResponse(response) self.events.emit(chat_service.SIGNAL_CHAT_UPDATE, - ChatUpdateArgsNew(messages: messages, chats: chats)) + ChatUpdateArgs(messages: messages, chats: chats)) except Exception as e: error "Error marking as accepted", msg = e.msg diff --git a/src/app_service/service/chat/service.nim b/src/app_service/service/chat/service.nim index ee45e27dcf..01bf156b93 100644 --- a/src/app_service/service/chat/service.nim +++ b/src/app_service/service/chat/service.nim @@ -24,8 +24,7 @@ logScope: include ../../common/json_utils type - # TODO remove New when refactored - ChatUpdateArgsNew* = ref object of Args + ChatUpdateArgs* = ref object of Args chats*: seq[ChatDto] messages*: seq[MessageDto] # TODO refactor that part @@ -37,6 +36,9 @@ type # statusUpdates*: seq[StatusUpdate] # deletedMessages*: seq[RemovedMessage] + CreatedChatArgs* = ref object of Args + chat*: ChatDto + ChatArgs* = ref object of Args communityId*: string # This param should be renamed to `sectionId`, that will avoid some confusions one may have. chatId*: string @@ -86,6 +88,7 @@ const SIGNAL_CHAT_MEMBER_REMOVED* = "chatMemberRemoved" const SIGNAL_CHAT_MEMBER_UPDATED* = "chatMemberUpdated" const SIGNAL_CHAT_SWITCH_TO_OR_CREATE_1_1_CHAT* = "switchToOrCreateOneToOneChat" const SIGNAL_CHAT_ADDED_OR_UPDATED* = "chatAddedOrUpdated" +const SIGNAL_CHAT_CREATED* = "chatCreated" QtObject: type Service* = ref object of QObject @@ -117,7 +120,7 @@ QtObject: if (chatDto.active): chats.add(chatDto) self.updateOrAddChat(chatDto) - self.events.emit(SIGNAL_CHAT_UPDATE, ChatUpdateArgsNew(messages: receivedData.messages, chats: chats)) + self.events.emit(SIGNAL_CHAT_UPDATE, ChatUpdateArgs(messages: receivedData.messages, chats: chats)) if (receivedData.clearedHistories.len > 0): for clearedHistoryDto in receivedData.clearedHistories: @@ -227,7 +230,7 @@ QtObject: proc emitUpdate(self: Service, response: RpcResponse[JsonNode]) = var (chats, messages) = self.parseChatResponse(response) - self.events.emit(SIGNAL_CHAT_UPDATE, ChatUpdateArgsNew(messages: messages, chats: chats)) + self.events.emit(SIGNAL_CHAT_UPDATE, ChatUpdateArgs(messages: messages, chats: chats)) proc getAllChats*(self: Service): seq[ChatDto] = return toSeq(self.chats.values) @@ -283,6 +286,8 @@ QtObject: let response = status_group_chat.createOneToOneChat(communityID, chatId, ensName) result = self.createChatFromResponse(response) + if result.success: + self.events.emit(SIGNAL_CHAT_CREATED, CreatedChatArgs(chat: result.chatDto)) except Exception as e: let errDesription = e.msg error "error: ", errDesription @@ -517,6 +522,8 @@ QtObject: try: let response = status_group_chat.createGroupChat(communityID, name, members) result = self.createChatFromResponse(response) + if result.success: + self.events.emit(SIGNAL_CHAT_CREATED, CreatedChatArgs(chat: result.chatDto)) except Exception as e: error "error while creating group chat", msg = e.msg diff --git a/ui/app/AppLayouts/Chat/views/ChatColumnView.qml b/ui/app/AppLayouts/Chat/views/ChatColumnView.qml index 164ad49541..f918d1ae2b 100644 --- a/ui/app/AppLayouts/Chat/views/ChatColumnView.qml +++ b/ui/app/AppLayouts/Chat/views/ChatColumnView.qml @@ -32,7 +32,6 @@ Item { property var rootStore property var contactsStore - property var chatSectionModule property var emojiPopup property Component pinnedMessagesPopupComponent @@ -166,12 +165,6 @@ Item { onShareChatKeyClicked: Global.openProfilePopup(userProfile.pubKey); } - CreateChatView { - rootStore: root.rootStore - emojiPopup: root.emojiPopup - visible: mainModule.activeSection.sectionType === Constants.appSection.chat && root.rootStore.openCreateChat - } - // This is kind of a solution for applying backend refactored changes with the minimal qml changes. // The best would be if we made qml to follow the struct we have on the backend side. Repeater { @@ -288,7 +281,6 @@ Item { Component.onCompleted: { parentModule.prepareChatContentModuleForChatId(model.itemId) chatContentModule = parentModule.getChatContentModule() - root.checkForCreateChatOptions(model.itemId) } } @@ -409,7 +401,7 @@ Item { height: root.height - 56 * 2 // TODO get screen size // Taken from old code top bar height was fixed there to 56 y: 56 store: root.rootStore - chatSectionModule: root.chatSectionModule + chatSectionModule: root.parentModule messageContextMenu: contextmenu } diff --git a/ui/app/AppLayouts/Chat/views/ChatView.qml b/ui/app/AppLayouts/Chat/views/ChatView.qml index 97b85f3eda..cb2ea37fdc 100644 --- a/ui/app/AppLayouts/Chat/views/ChatView.qml +++ b/ui/app/AppLayouts/Chat/views/ChatView.qml @@ -53,6 +53,13 @@ StatusAppThreePanelLayout { } } + Connections { + target: Global + onCloseCreateChatView: { + root.rootStore.openCreateChat = false + } + } + leftPanel: Loader { id: contactColumnLoader sourceComponent: root.rootStore.chatCommunitySectionModule.isCommunity()? @@ -65,7 +72,6 @@ StatusAppThreePanelLayout { parentModule: root.rootStore.chatCommunitySectionModule rootStore: root.rootStore contactsStore: root.contactsStore - chatSectionModule: root.rootStore.chatCommunitySectionModule pinnedMessagesPopupComponent: root.pinnedMessagesListPopupComponent stickersLoaded: root.stickersLoaded emojiPopup: root.emojiPopup diff --git a/ui/app/AppLayouts/Chat/views/CommunityColumnView.qml b/ui/app/AppLayouts/Chat/views/CommunityColumnView.qml index 1904e21c67..31d8da97fe 100644 --- a/ui/app/AppLayouts/Chat/views/CommunityColumnView.qml +++ b/ui/app/AppLayouts/Chat/views/CommunityColumnView.qml @@ -4,10 +4,12 @@ import QtQuick.Dialogs 1.2 import QtGraphicalEffects 1.13 import QtQuick.Layouts 1.13 +import StatusQ.Core 0.1 +import StatusQ.Core.Theme 0.1 +import StatusQ.Controls 0.1 import StatusQ.Components 0.1 import StatusQ.Popups 0.1 - import utils 1.0 import shared 1.0 import shared.popups 1.0 @@ -35,56 +37,49 @@ Item { signal infoButtonClicked signal manageButtonClicked - StatusChatInfoToolBar { + StatusChatInfoButton { id: communityHeader - anchors.top: parent.top - anchors.horizontalCenter: parent.horizontalCenter - - chatInfoButton.title: communityData.name - chatInfoButton.subTitle: communityData.members.count <= 1 ? + title: communityData.name + subTitle: communityData.members.count <= 1 ? //% "1 Member" qsTrId("1-member") : //% "%1 Members" qsTrId("-1-members").arg(communityData.members.count) + image.source: communityData.image + icon.color: communityData.color + onClicked: root.infoButtonClicked() + anchors.top: parent.top + anchors.topMargin: 5 + anchors.left: parent.left + anchors.leftMargin: Style.current.halfPadding + anchors.right: (implicitWidth > parent.width - 50) ? adHocChatButton.left : undefined + anchors.rightMargin: Style.current.halfPadding + type: StatusChatInfoButton.Type.OneToOneChat + } - chatInfoButton.image.source: communityData.image - chatInfoButton.icon.color: communityData.color - menuButton.visible: communityData.amISectionAdmin && communityData.canManageUsers - chatInfoButton.onClicked: root.infoButtonClicked() - - popupMenu: StatusPopupMenu { - StatusMenuItem { - //% "Create channel" - text: qsTrId("create-channel") - icon.name: "channel" - enabled: communityData.amISectionAdmin - onTriggered: Global.openPopup(createChannelPopup) - } - - StatusMenuItem { - //% "Create category" - text: qsTrId("create-category") - icon.name: "channel-category" - enabled: communityData.amISectionAdmin - onTriggered: Global.openPopup(createCategoryPopup) - } - - StatusMenuSeparator {} - - StatusMenuItem { - //% "Invite people" - text: qsTrId("invite-people") - icon.name: "share-ios" - enabled: communityData.canManageUsers - onTriggered: Global.openPopup(inviteFriendsToCommunityPopup, { - community: communityData, - hasAddedContacts: root.hasAddedContacts, - communitySectionModule: root.communitySectionModule - }) + StatusIconTabButton { + id: adHocChatButton + icon.name: "edit" + anchors.verticalCenter: communityHeader.verticalCenter + anchors.right: parent.right + anchors.rightMargin: 14 + checked: root.store.openCreateChat + highlighted: root.store.openCreateChat + onClicked: { + root.store.openCreateChat = !root.store.openCreateChat; + if (!root.store.openCreateChat) { + Global.closeCreateChatView() + } else { + Global.openCreateChatView() } } + StatusToolTip { + text: qsTr("Start chat") + visible: parent.hovered + } } // StatusChatInfoToolBar + Loader { id: membershipRequests @@ -111,7 +106,9 @@ Item { ScrollView { id: chatGroupsContainer anchors.top: membershipRequests.bottom - anchors.bottom: parent.bottom + anchors.topMargin: Style.current.padding + anchors.bottom: createChatOrCommunity.top + anchors.horizontalCenter: parent.horizontalCenter topPadding: Style.current.padding @@ -466,6 +463,53 @@ Item { } // Column } // ScrollView + Loader { + id: createChatOrCommunity + anchors.horizontalCenter: parent.horizontalCenter + anchors.bottom: parent.bottom + anchors.bottomMargin: Style.current.padding + active: communityData.amISectionAdmin + sourceComponent: Component { + StatusBaseText { + color: Theme.palette.baseColor1 + height: visible ? implicitHeight : 0 + text: qsTr("Create channel or category") + font.underline: true + font.pixelSize: 13 + textFormat: Text.RichText + + MouseArea { + anchors.fill: parent + cursorShape: Qt.PointingHandCursor + onClicked: { + if (createChatOrCatMenu.opened) { + createChatOrCatMenu.close() + return + } + createChatOrCatMenu.open() + createChatOrCatMenu.y = - createChatOrCatMenu.height - 5 + } + } + + StatusPopupMenu { + id: createChatOrCatMenu + closePolicy: Popup.CloseOnPressOutsideParent + StatusMenuItem { + text: qsTr("Create channel") + icon.name: "channel" + onTriggered: Global.openPopup(createChannelPopup) + } + + StatusMenuItem { + text: qsTrId("Create category") + icon.name: "channel-category" + onTriggered: Global.openPopup(createCategoryPopup) + } + } + } + } + } + Component { id: createChannelPopup CreateChannelPopup { diff --git a/ui/app/AppLayouts/Chat/views/ContactsColumnView.qml b/ui/app/AppLayouts/Chat/views/ContactsColumnView.qml index 81d71eb47a..b98e891e23 100644 --- a/ui/app/AppLayouts/Chat/views/ContactsColumnView.qml +++ b/ui/app/AppLayouts/Chat/views/ContactsColumnView.qml @@ -120,6 +120,11 @@ Item { highlighted: root.store.openCreateChat onClicked: { root.store.openCreateChat = !root.store.openCreateChat; + if (!root.store.openCreateChat) { + Global.closeCreateChatView() + } else { + Global.openCreateChatView() + } } StatusToolTip { diff --git a/ui/app/AppLayouts/Chat/views/CreateChatView.qml b/ui/app/AppLayouts/Chat/views/CreateChatView.qml index 670a4cb377..a757185540 100644 --- a/ui/app/AppLayouts/Chat/views/CreateChatView.qml +++ b/ui/app/AppLayouts/Chat/views/CreateChatView.qml @@ -14,7 +14,6 @@ import shared.status 1.0 Page { id: root - anchors.fill: parent Behavior on anchors.bottomMargin { NumberAnimation { duration: 30 }} property ListModel contactsModel: ListModel { } @@ -22,6 +21,7 @@ Page { property var emojiPopup: null Keys.onEscapePressed: { + Global.closeCreateChatView() root.rootStore.openCreateChat = false; } @@ -37,21 +37,18 @@ Page { } } - Connections { - target: rootStore - onOpenCreateChatChanged: { - if (root.rootStore.openCreateChat) { - for (var i = 0; i < contactsModelListView.count; i ++) { - var entry = contactsModelListView.itemAtIndex(i); - contactsModel.insert(contactsModel.count, - {"pubKey": entry.pubKey, "displayName": entry.displayName, - "icon": entry.icon}); - } - tagSelector.sortModel(root.contactsModel); - } else { - contactsModel.clear(); - tagSelector.namesModel.clear(); + onVisibleChanged: { + if (visible) { + for (var i = 0; i < contactsModelListView.count; i ++) { + var entry = contactsModelListView.itemAtIndex(i); + contactsModel.insert(contactsModel.count, + {"pubKey": entry.pubKey, "displayName": entry.displayName, + "icon": entry.icon}); } + tagSelector.sortModel(root.contactsModel); + } else { + contactsModel.clear(); + tagSelector.namesModel.clear(); } } @@ -66,22 +63,15 @@ Page { groupName += (tagSelector.namesModel.get(i).name + (i === tagSelector.namesModel.count - 1 ? "" : "&")); pubKeys.push(tagSelector.namesModel.get(i).pubKey); } - root.rootStore.chatCommunitySectionModule.createGroupChat("",groupName, JSON.stringify(pubKeys)); + root.rootStore.chatCommunitySectionModule.createGroupChat("", groupName, JSON.stringify(pubKeys)); } chatInput.textInput.clear(); chatInput.textInput.textFormat = TextEdit.PlainText; chatInput.textInput.textFormat = TextEdit.RichText; + Global.changeAppSectionBySectionType(Constants.appSection.chat) } - visible: (opacity > 0.01) - onVisibleChanged: { - if (!visible) { - tagSelector.namesModel.clear(); - } - } - - opacity: (root.rootStore.openCreateChat) ? 1.0 : 0.0 Behavior on opacity { NumberAnimation {}} background: Rectangle { anchors.fill: parent @@ -95,8 +85,6 @@ Page { height: tagSelector.height anchors.top: parent.top anchors.topMargin: 8 - anchors.right: parent.right - anchors.rightMargin: 8 clip: true StatusTagSelector { id: tagSelector diff --git a/ui/app/AppLayouts/Chat/views/qmldir b/ui/app/AppLayouts/Chat/views/qmldir new file mode 100644 index 0000000000..b14fdf1222 --- /dev/null +++ b/ui/app/AppLayouts/Chat/views/qmldir @@ -0,0 +1 @@ +CreateChatView 1.0 CreateChatView.qml diff --git a/ui/app/mainui/AppMain.qml b/ui/app/mainui/AppMain.qml index 58d37c714c..1087119290 100644 --- a/ui/app/mainui/AppMain.qml +++ b/ui/app/mainui/AppMain.qml @@ -11,6 +11,7 @@ import AppLayouts.Node 1.0 import AppLayouts.Browser 1.0 import AppLayouts.Chat 1.0 import AppLayouts.Chat.popups 1.0 +import AppLayouts.Chat.views 1.0 import AppLayouts.Profile 1.0 import AppLayouts.Profile.popups 1.0 import AppLayouts.CommunitiesPortal 1.0 @@ -441,201 +442,236 @@ Item { } } - StackLayout { - id: appView + + Item { width: parent.width - Layout.fillHeight: true - currentIndex: { - if(mainModule.activeSection.sectionType === Constants.appSection.chat) { - return Constants.appViewStackIndex.chat - } - else if(mainModule.activeSection.sectionType === Constants.appSection.community) { + StackLayout { + id: appView - for(let i = this.children.length - 1; i >=0; i--) - { - var obj = this.children[i]; - if(obj && obj.sectionId && obj.sectionId == mainModule.activeSection.id) + anchors.fill: parent + + currentIndex: { + if(mainModule.activeSection.sectionType === Constants.appSection.chat) { + return Constants.appViewStackIndex.chat + } + else if(mainModule.activeSection.sectionType === Constants.appSection.community) { + + for(let i = this.children.length - 1; i >=0; i--) { - return i + var obj = this.children[i]; + if(obj && obj.sectionId && obj.sectionId == mainModule.activeSection.id) + { + return i + } } + + // Should never be here, correct index must be returned from the for loop above + console.error("Wrong section type: ", mainModule.activeSection.sectionType, + " or section id: ", mainModule.activeSection.id) + return Constants.appViewStackIndex.community + } + else if(mainModule.activeSection.sectionType === Constants.appSection.communitiesPortal) { + return Constants.appViewStackIndex.communitiesPortal + } + else if(mainModule.activeSection.sectionType === Constants.appSection.wallet) { + return Constants.appViewStackIndex.wallet + } + else if(mainModule.activeSection.sectionType === Constants.appSection.browser) { + return Constants.appViewStackIndex.browser + } + else if(mainModule.activeSection.sectionType === Constants.appSection.profile) { + return Constants.appViewStackIndex.profile + } + else if(mainModule.activeSection.sectionType === Constants.appSection.node) { + return Constants.appViewStackIndex.node } - // Should never be here, correct index must be returned from the for loop above - console.error("Wrong section type: ", mainModule.activeSection.sectionType, - " or section id: ", mainModule.activeSection.id) - return Constants.appViewStackIndex.community - } - else if(mainModule.activeSection.sectionType === Constants.appSection.communitiesPortal) { - return Constants.appViewStackIndex.communitiesPortal - } - else if(mainModule.activeSection.sectionType === Constants.appSection.wallet) { - return Constants.appViewStackIndex.wallet - } - else if(mainModule.activeSection.sectionType === Constants.appSection.browser) { - return Constants.appViewStackIndex.browser - } - else if(mainModule.activeSection.sectionType === Constants.appSection.profile) { - return Constants.appViewStackIndex.profile - } - else if(mainModule.activeSection.sectionType === Constants.appSection.node) { - return Constants.appViewStackIndex.node + // We should never end up here + console.error("Unknown section type") } - // We should never end up here - console.error("Unknown section type") - } + onCurrentIndexChanged: { + var obj = this.children[currentIndex]; + if(!obj) + return - onCurrentIndexChanged: { - var obj = this.children[currentIndex]; - if(!obj) - return + if (obj.onActivated && typeof obj.onActivated === "function") { + this.children[currentIndex].onActivated() + } - if (obj.onActivated && typeof obj.onActivated === "function") { - this.children[currentIndex].onActivated() + if(obj === browserLayoutContainer && browserLayoutContainer.active == false){ + browserLayoutContainer.active = true; + } + + if(obj === walletLayoutContainer){ + walletLayoutContainer.showSigningPhrasePopup(); + } } - if(obj === browserLayoutContainer && browserLayoutContainer.active == false){ - browserLayoutContainer.active = true; + // NOTE: + // If we ever change stack layout component order we need to updade + // Constants.appViewStackIndex accordingly + + ChatLayout { + id: chatLayoutContainer + Layout.fillWidth: true + Layout.alignment: Qt.AlignLeft | Qt.AlignTop + Layout.fillHeight: true + + chatView.pinnedMessagesListPopupComponent: pinnedMessagesPopupComponent + chatView.emojiPopup: statusEmojiPopup + + contactsStore: appMain.rootStore.contactStore + rootStore.emojiReactionsModel: appMain.rootStore.emojiReactionsModel + + chatView.onProfileButtonClicked: { + Global.changeAppSectionBySectionType(Constants.appSection.profile); + } + + chatView.onOpenAppSearch: { + appSearch.openSearchPopup() + } + + Component.onCompleted: { + rootStore.chatCommunitySectionModule = mainModule.getChatSectionModule() + } } - if(obj === walletLayoutContainer){ - walletLayoutContainer.showSigningPhrasePopup(); - } - } - - // NOTE: - // If we ever change stack layout component order we need to updade - // Constants.appViewStackIndex accordingly - - ChatLayout { - id: chatLayoutContainer - Layout.fillWidth: true - Layout.alignment: Qt.AlignLeft | Qt.AlignTop - Layout.fillHeight: true - - chatView.pinnedMessagesListPopupComponent: pinnedMessagesPopupComponent - chatView.emojiPopup: statusEmojiPopup - - contactsStore: appMain.rootStore.contactStore - rootStore.emojiReactionsModel: appMain.rootStore.emojiReactionsModel - - chatView.onProfileButtonClicked: { - Global.changeAppSectionBySectionType(Constants.appSection.profile); + CommunitiesPortalLayout { + id: communitiesPortalLayoutContainer + Layout.fillWidth: true + Layout.alignment: Qt.AlignLeft | Qt.AlignTop + Layout.fillHeight: true } - chatView.onOpenAppSearch: { - appSearch.openSearchPopup() + WalletLayout { + id: walletLayoutContainer + Layout.fillWidth: true + Layout.alignment: Qt.AlignLeft | Qt.AlignTop + Layout.fillHeight: true + store: appMain.rootStore + contactsStore: appMain.rootStore.profileSectionStore.contactsStore + emojiPopup: statusEmojiPopup + sendModal: sendModal } - Component.onCompleted: { - rootStore.chatCommunitySectionModule = mainModule.getChatSectionModule() + Component { + id: browserLayoutComponent + BrowserLayout { + globalStore: appMain.rootStore + sendTransactionModal: sendModal + } } - } - CommunitiesPortalLayout { - id: communitiesPortalLayoutContainer - Layout.fillWidth: true - Layout.alignment: Qt.AlignLeft | Qt.AlignTop - Layout.fillHeight: true - } + Loader { + id: browserLayoutContainer + sourceComponent: browserLayoutComponent + active: false + Layout.fillWidth: true + Layout.alignment: Qt.AlignLeft | Qt.AlignTop + Layout.fillHeight: true + // Loaders do not have access to the context, so props need to be set + // Adding a "_" to avoid a binding loop + // Not Refactored Yet + // property var _chatsModel: chatsModel.messageView + // Not Refactored Yet + // property var _walletModel: walletModel + // Not Refactored Yet + // property var _utilsModel: utilsModel + property var _web3Provider: BrowserStores.Web3ProviderStore.web3ProviderInst + } - WalletLayout { - id: walletLayoutContainer - Layout.fillWidth: true - Layout.alignment: Qt.AlignLeft | Qt.AlignTop - Layout.fillHeight: true - store: appMain.rootStore - contactsStore: appMain.rootStore.profileSectionStore.contactsStore - emojiPopup: statusEmojiPopup - sendModal: sendModal - } + ProfileLayout { + id: profileLayoutContainer + Layout.fillWidth: true + Layout.alignment: Qt.AlignLeft | Qt.AlignTop + Layout.fillHeight: true - Component { - id: browserLayoutComponent - BrowserLayout { + store: appMain.rootStore.profileSectionStore globalStore: appMain.rootStore - sendTransactionModal: sendModal + systemPalette: appMain.sysPalette + emojiPopup: statusEmojiPopup } - } + NodeLayout { + id: nodeLayoutContainer + Layout.fillWidth: true + Layout.alignment: Qt.AlignLeft | Qt.AlignTop + Layout.fillHeight: true + } - Loader { - id: browserLayoutContainer - sourceComponent: browserLayoutComponent - active: false - Layout.fillWidth: true - Layout.alignment: Qt.AlignLeft | Qt.AlignTop - Layout.fillHeight: true - // Loaders do not have access to the context, so props need to be set - // Adding a "_" to avoid a binding loop - // Not Refactored Yet - // property var _chatsModel: chatsModel.messageView - // Not Refactored Yet - // property var _walletModel: walletModel - // Not Refactored Yet - // property var _utilsModel: utilsModel - property var _web3Provider: BrowserStores.Web3ProviderStore.web3ProviderInst - } + Repeater { + model: mainModule.sectionsModel - ProfileLayout { - id: profileLayoutContainer - Layout.fillWidth: true - Layout.alignment: Qt.AlignLeft | Qt.AlignTop - Layout.fillHeight: true + delegate: DelegateChooser { + id: delegateChooser + role: "sectionType" + DelegateChoice { + roleValue: Constants.appSection.community + delegate: ChatLayout { + property string sectionId: model.id + Layout.fillWidth: true + Layout.alignment: Qt.AlignLeft | Qt.AlignTop + Layout.fillHeight: true - store: appMain.rootStore.profileSectionStore - globalStore: appMain.rootStore - systemPalette: appMain.sysPalette - emojiPopup: statusEmojiPopup - } + chatView.pinnedMessagesListPopupComponent: pinnedMessagesPopupComponent + chatView.emojiPopup: statusEmojiPopup - NodeLayout { - id: nodeLayoutContainer - Layout.fillWidth: true - Layout.alignment: Qt.AlignLeft | Qt.AlignTop - Layout.fillHeight: true - } + contactsStore: appMain.rootStore.contactStore + rootStore.emojiReactionsModel: appMain.rootStore.emojiReactionsModel - Repeater { - model: mainModule.sectionsModel + chatView.onProfileButtonClicked: { + Global.changeAppSectionBySectionType(Constants.appSection.profile); + } - delegate: DelegateChooser { - id: delegateChooser - role: "sectionType" - DelegateChoice { - roleValue: Constants.appSection.community - delegate: ChatLayout { - property string sectionId: model.id - Layout.fillWidth: true - Layout.alignment: Qt.AlignLeft | Qt.AlignTop - Layout.fillHeight: true + chatView.onOpenAppSearch: { + appSearch.openSearchPopup() + } - chatView.pinnedMessagesListPopupComponent: pinnedMessagesPopupComponent - chatView.emojiPopup: statusEmojiPopup - - contactsStore: appMain.rootStore.contactStore - rootStore.emojiReactionsModel: appMain.rootStore.emojiReactionsModel - - chatView.onProfileButtonClicked: { - Global.changeAppSectionBySectionType(Constants.appSection.profile); - } - - chatView.onOpenAppSearch: { - appSearch.openSearchPopup() - } - - Component.onCompleted: { - // we cannot return QVariant if we pass another parameter in a function call - // that's why we're using it this way - mainModule.prepareCommunitySectionModuleForCommunityId(model.id) - rootStore.chatCommunitySectionModule = mainModule.getCommunitySectionModule() + Component.onCompleted: { + // we cannot return QVariant if we pass another parameter in a function call + // that's why we're using it this way + mainModule.prepareCommunitySectionModuleForCommunityId(model.id) + rootStore.chatCommunitySectionModule = mainModule.getCommunitySectionModule() + } } } } } } + + CreateChatView { + property bool opened: false + + id: createChatView + rootStore: chatLayoutContainer.rootStore + emojiPopup: statusEmojiPopup + anchors.top: parent.top + anchors.topMargin: 8 + anchors.rightMargin: 8 + anchors.bottom: parent.bottom + anchors.right: parent.right + width: chatLayoutContainer.chatView.width - chatLayoutContainer.chatView.leftPanel.width - anchors.rightMargin - anchors.leftMargin + visible: createChatView.opened + + Connections { + target: Global + onOpenCreateChatView: { + createChatView.opened = true + } + onCloseCreateChatView: { + createChatView.opened = false + } + } + Connections { + target: mainModule + onActiveSectionChanged: { + Global.closeCreateChatView() + } + } + } } Connections { diff --git a/ui/imports/utils/Global.qml b/ui/imports/utils/Global.qml index 3c223a4eba..39b77b1d74 100644 --- a/ui/imports/utils/Global.qml +++ b/ui/imports/utils/Global.qml @@ -26,6 +26,8 @@ QtObject { signal openDownloadModalRequested() signal settingsLoaded() signal openBackUpSeedPopup() + signal openCreateChatView() + signal closeCreateChatView() signal openProfilePopupRequested(string publicKey, var parentPopup, bool openNicknamePopup) signal openChangeProfilePicPopup()