From f0ca1a4cc3f01355175754b2c8464a546658b1ca Mon Sep 17 00:00:00 2001 From: Sale Djenic Date: Wed, 12 Jan 2022 00:16:17 +0100 Subject: [PATCH] refactor(@desktop/general): many errors from the log are fixed - various issues on app start in console - various issues when logging out in console - `node_section` module delete method error - SyntaxError: JSON.parse: Parse error from the MessageStore --- src/app/boot/app_controller.nim | 1 + .../modules/main/node_section/controller.nim | 2 +- .../Chat/panels/SuggestionBoxPanel.qml | 2 +- .../AppLayouts/Chat/stores/MessageStore.qml | 14 ++- ui/app/AppLayouts/Chat/stores/RootStore.qml | 2 - .../AppLayouts/Chat/views/ChatColumnView.qml | 10 +- .../AppLayouts/Chat/views/ChatContentView.qml | 99 ++++++++++++++++--- .../Chat/views/ChatMessagesView.qml | 4 +- ui/app/AppLayouts/Node/NodeLayout.qml | 6 ++ .../Profile/stores/AdvancedStore.qml | 48 +++++++-- .../AppLayouts/Profile/views/SoundsView.qml | 5 +- .../AppLayouts/Wallet/views/RightTabView.qml | 2 +- .../WalletV2/panels/WalletHeaderPanel.qml | 6 +- ui/app/AppMain.qml | 14 ++- ui/imports/shared/controls/StyledTextArea.qml | 2 - ui/imports/shared/status/StatusChatInput.qml | 11 ++- .../status/StatusEmojiSuggestionPopup.qml | 8 +- ui/imports/shared/stores/RootStore.qml | 32 +++--- ui/imports/utils/Global.qml | 13 +-- ui/main.qml | 33 ++++--- 20 files changed, 225 insertions(+), 89 deletions(-) diff --git a/src/app/boot/app_controller.nim b/src/app/boot/app_controller.nim index 1a3a92ddf1..b700addad4 100644 --- a/src/app/boot/app_controller.nim +++ b/src/app/boot/app_controller.nim @@ -207,6 +207,7 @@ proc newAppController*(statusFoundation: StatusFoundation): AppController = result.connect() proc delete*(self: AppController) = + singletonInstance.delete self.osNotificationService.delete self.keychainService.delete self.contactsService.delete diff --git a/src/app/modules/main/node_section/controller.nim b/src/app/modules/main/node_section/controller.nim index 2b26168736..38c66c1559 100644 --- a/src/app/modules/main/node_section/controller.nim +++ b/src/app/modules/main/node_section/controller.nim @@ -34,7 +34,7 @@ proc newController*(delegate: io_interface.AccessInterface, result.nodeService = nodeService result.nodeConfigurationService = nodeConfigurationService -proc delete*(self: Controller) = +method delete*(self: Controller) = discard proc setPeers(self: Controller, peers: seq[string]) = diff --git a/ui/app/AppLayouts/Chat/panels/SuggestionBoxPanel.qml b/ui/app/AppLayouts/Chat/panels/SuggestionBoxPanel.qml index ec9f211c80..1f6cf1e47a 100644 --- a/ui/app/AppLayouts/Chat/panels/SuggestionBoxPanel.qml +++ b/ui/app/AppLayouts/Chat/panels/SuggestionBoxPanel.qml @@ -33,7 +33,7 @@ import shared.panels 1.0 Rectangle { id: container - property QtObject model: undefined + property QtObject model property Item delegate property alias suggestionsModel: filterItem.model property alias filter: filterItem.filter diff --git a/ui/app/AppLayouts/Chat/stores/MessageStore.qml b/ui/app/AppLayouts/Chat/stores/MessageStore.qml index c71ed4a589..df0fc78ab4 100644 --- a/ui/app/AppLayouts/Chat/stores/MessageStore.qml +++ b/ui/app/AppLayouts/Chat/stores/MessageStore.qml @@ -5,7 +5,13 @@ QtObject { id: root property var messageModule - property var messagesModel: messageModule.model + property var messagesModel + + onMessageModuleChanged: { + if(!messageModule) + return + root.messagesModel = messageModule.model + } function loadMoreMessages () { if(!messageModule) @@ -21,6 +27,9 @@ QtObject { return false let jsonObj = messageModule.getMessageByIdAsJson(id) + if(jsonObj === "") + return + let obj = JSON.parse(jsonObj) if (obj.error) { // This log is available only in debug mode, if it's annoying we can remove it @@ -36,6 +45,9 @@ QtObject { return false let jsonObj = messageModule.getMessageByIndexAsJson(index) + if(jsonObj === "") + return + let obj = JSON.parse(jsonObj) if (obj.error) { // This log is available only in debug mode, if it's annoying we can remove it diff --git a/ui/app/AppLayouts/Chat/stores/RootStore.qml b/ui/app/AppLayouts/Chat/stores/RootStore.qml index 0f354797f2..0690cfab24 100644 --- a/ui/app/AppLayouts/Chat/stores/RootStore.qml +++ b/ui/app/AppLayouts/Chat/stores/RootStore.qml @@ -67,8 +67,6 @@ QtObject { property var userProfileInst: userProfile - property bool isDebugEnabled: profileSectionModule.isDebugEnabled - property var accounts: walletSectionAccounts.model property var currentAccount: walletSectionCurrent property var currentCurrency: walletSection.currentCurrency diff --git a/ui/app/AppLayouts/Chat/views/ChatColumnView.qml b/ui/app/AppLayouts/Chat/views/ChatColumnView.qml index 9d49543e64..72075ea1c4 100644 --- a/ui/app/AppLayouts/Chat/views/ChatColumnView.qml +++ b/ui/app/AppLayouts/Chat/views/ChatColumnView.qml @@ -52,9 +52,9 @@ Item { property Timer timer: Timer { } property var userList - property var contactDetails: Utils.getContactDetailsAsJson(publicKey) - property bool isBlocked: root.contactDetails.isContact - property bool isContact: root.contactDetails.isBlocked + property var contactDetails: Utils.getContactDetailsAsJson(root.activeChatId) + property bool isBlocked: root.contactDetails.isBlocked + property bool isContact: root.contactDetails.isContact property bool contactRequestReceived: root.contactDetails.requestReceived signal openAppSearch() @@ -172,10 +172,6 @@ Item { } } - - // Should never be here, correct index must be returned from the `for` loop above - console.error("Wrong chat/channel index, active item id: ", root.activeChatId, - " active subitem id: ", root.activeSubItemId) } return 0 diff --git a/ui/app/AppLayouts/Chat/views/ChatContentView.qml b/ui/app/AppLayouts/Chat/views/ChatContentView.qml index d06dd43cba..67c337fed6 100644 --- a/ui/app/AppLayouts/Chat/views/ChatContentView.qml +++ b/ui/app/AppLayouts/Chat/views/ChatContentView.qml @@ -42,8 +42,11 @@ ColumnLayout { id: topBar Layout.fillWidth: true - chatInfoButton.title: chatContentModule.chatDetails.name + chatInfoButton.title: chatContentModule? chatContentModule.chatDetails.name : "" chatInfoButton.subTitle: { + if(!chatContentModule) + return "" + // In some moment in future this should be part of the backend logic. // (once we add transaltion on the backend side) switch (chatContentModule.chatDetails.type) { @@ -68,24 +71,39 @@ ColumnLayout { return "" } } - chatInfoButton.image.source: chatContentModule.chatDetails.icon - chatInfoButton.image.isIdenticon: chatContentModule.chatDetails.isIdenticon - chatInfoButton.icon.color: chatContentModule.chatDetails.color - chatInfoButton.type: chatContentModule.chatDetails.type - chatInfoButton.pinnedMessagesCount: chatContentModule.pinnedMessagesModel.count - chatInfoButton.muted: chatContentModule.chatDetails.muted + chatInfoButton.image.source: chatContentModule? chatContentModule.chatDetails.icon : "" + chatInfoButton.image.isIdenticon: chatContentModule? chatContentModule.chatDetails.isIdenticon : false + chatInfoButton.icon.color: chatContentModule? chatContentModule.chatDetails.color : "" + chatInfoButton.type: chatContentModule? chatContentModule.chatDetails.type : Constants.chatType.unknown + chatInfoButton.pinnedMessagesCount: chatContentModule? chatContentModule.pinnedMessagesModel.count : 0 + chatInfoButton.muted: chatContentModule? chatContentModule.chatDetails.muted : false chatInfoButton.onPinnedMessagesCountClicked: { + if(!chatContentModule) { + console.debug("error on open pinned messages - chat content module is not set") + return + } Global.openPopup(pinnedMessagesPopupComponent, { messageStore: messageStore, pinnedMessagesModel: chatContentModule.pinnedMessagesModel, messageToPin: "" }) } - chatInfoButton.onUnmute: chatContentModule.unmuteChat() + chatInfoButton.onUnmute: { + if(!chatContentModule) { + console.debug("error on unmute chat - chat content module is not set") + return + } + chatContentModule.unmuteChat() + } - chatInfoButton.sensor.enabled: chatContentModule.chatDetails.type !== Constants.chatType.publicChat && - chatContentModule.chatDetails.type !== Constants.chatType.communityChat + chatInfoButton.sensor.enabled: { + if(!chatContentModule) + return false + + return chatContentModule.chatDetails.type !== Constants.chatType.publicChat && + chatContentModule.chatDetails.type !== Constants.chatType.communityChat + } chatInfoButton.onClicked: { // Not Refactored Yet // switch (chatContentRoot.rootStore.chatsModelInst.channelView.activeChannel.chatType) { @@ -101,12 +119,23 @@ ColumnLayout { // } } - membersButton.visible: localAccountSensitiveSettings.showOnlineUsers && chatContentModule.chatDetails.isUsersListAvailable + membersButton.visible: { + if(!chatContentModule) + return false + + return localAccountSensitiveSettings.showOnlineUsers && + chatContentModule.chatDetails.isUsersListAvailable + } membersButton.highlighted: localAccountSensitiveSettings.expandUsersList notificationButton.visible: localAccountSensitiveSettings.isActivityCenterEnabled notificationButton.tooltip.offset: localAccountSensitiveSettings.expandUsersList ? 0 : 14 - notificationCount: chatContentModule.chatDetails.notificationCount + notificationCount: { + if(!chatContentModule) + return 0 + + return chatContentModule.chatDetails.notificationCount + } onSearchButtonClicked: root.openAppSearch() @@ -115,6 +144,10 @@ ColumnLayout { popupMenu: ChatContextMenuView { openHandler: function () { + if(!chatContentModule) { + console.debug("error on open chat context menu handler - chat content module is not set") + return + } currentFleet = chatContentModule.getCurrentFleet() isCommunityChat = chatContentModule.chatDetails.belongsToCommunity amIChatAdmin = chatContentModule.amIChatAdmin() @@ -126,18 +159,34 @@ ColumnLayout { } onMuteChat: { + if(!chatContentModule) { + console.debug("error on mute chat from context menu - chat content module is not set") + return + } chatContentModule.muteChat() } onUnmuteChat: { + if(!chatContentModule) { + console.debug("error on unmute chat from context menu - chat content module is not set") + return + } chatContentModule.unmuteChat() } onMarkAllMessagesRead: { + if(!chatContentModule) { + console.debug("error on mark all messages read from context menu - chat content module is not set") + return + } chatContentModule.markAllMessagesRead() } onClearChatHistory: { + if(!chatContentModule) { + console.debug("error on clear chat history from context menu - chat content module is not set") + return + } chatContentModule.clearChatHistory() } @@ -146,6 +195,10 @@ ColumnLayout { } onLeaveChat: { + if(!chatContentModule) { + console.debug("error on leave chat from context menu - chat content module is not set") + return + } chatContentModule.leaveChat() } @@ -170,6 +223,10 @@ ColumnLayout { } onOpenPinnedMessagesList: { + if(!chatContentModule) { + console.debug("error on open pinned messages from context menu - chat content module is not set") + return + } Global.openPopup(pinnedMessagesPopupComponent, { messageStore: messageStore, pinnedMessagesModel: chatContentModule.pinnedMessagesModel, @@ -245,7 +302,7 @@ ColumnLayout { MessageStore{ id: messageStore - messageModule: chatContentModule.messagesModule + messageModule: chatContentModule? chatContentModule.messagesModule : null } MessageContextMenuView { @@ -260,6 +317,10 @@ ColumnLayout { } onPinnedMessagesLimitReached: { + if(!chatContentModule) { + console.debug("error on open pinned messages limit reached from message context menu - chat content module is not set") + return + } Global.openPopup(pinnedMessagesPopupComponent, { messageStore: messageStore, pinnedMessagesModel: chatContentModule.pinnedMessagesModel, @@ -355,8 +416,13 @@ ColumnLayout { anchors.bottom: parent.bottom recentStickers: chatContentRoot.rootStore.stickersModuleInst.recent stickerPackList: chatContentRoot.rootStore.stickersModuleInst.stickerPacks - chatType: chatContentModule.chatDetails.type + chatType: chatContentModule? chatContentModule.chatDetails.type : Constants.chatType.unknown onSendTransactionCommandButtonClicked: { + if(!chatContentModule) { + console.debug("error on sending transaction command - chat content module is not set") + return + } + if (Utils.getContactDetailsAsJson(chatContentModule.getMyChatId()).ensVerified) { Global.openPopup(chatContentRoot.sendTransactionWithEnsModal) } else { @@ -373,6 +439,11 @@ ColumnLayout { packId) } onSendMessage: { + if(!chatContentModule) { + console.debug("error on sending message - chat content module is not set") + return + } + if (chatInput.fileUrls.length > 0){ chatContentModule.inputAreaModule.sendImages(JSON.stringify(fileUrls)); } diff --git a/ui/app/AppLayouts/Chat/views/ChatMessagesView.qml b/ui/app/AppLayouts/Chat/views/ChatMessagesView.qml index ac3ba7c7c5..e1bc8ae024 100644 --- a/ui/app/AppLayouts/Chat/views/ChatMessagesView.qml +++ b/ui/app/AppLayouts/Chat/views/ChatMessagesView.qml @@ -39,14 +39,14 @@ Item { Item { id: loadingMessagesIndicator - visible: messageStore.messageModule.loadingHistoryMessagesInProgress + visible: messageStore.messageModule? messageStore.messageModule.loadingHistoryMessagesInProgress : false anchors.top: parent.top anchors.left: parent.left height: visible? 20 : 0 width: parent.width Loader { - active: messageStore.messageModule.loadingHistoryMessagesInProgress + active: messageStore.messageModule? messageStore.messageModule.loadingHistoryMessagesInProgress : false anchors.horizontalCenter: parent.horizontalCenter anchors.verticalCenter: parent.verticalCenter sourceComponent: Component { diff --git a/ui/app/AppLayouts/Node/NodeLayout.qml b/ui/app/AppLayouts/Node/NodeLayout.qml index 681270ec34..d24e5a0749 100644 --- a/ui/app/AppLayouts/Node/NodeLayout.qml +++ b/ui/app/AppLayouts/Node/NodeLayout.qml @@ -94,6 +94,9 @@ Item { // TODO: replace with StatusTextArea once it lives in StatusQ. StyledTextArea { id: mailserverLogTxt + Layout.rightMargin: Style.current.padding + Layout.leftMargin: Style.current.padding + Layout.fillWidth: true text: "" customHeight: 200 textField.readOnly: true @@ -116,6 +119,9 @@ Item { // TODO: replace with StatusTextArea once it lives in StatusQ. StyledTextArea { id: logsTxt + Layout.rightMargin: Style.current.padding + Layout.leftMargin: Style.current.padding + Layout.fillWidth: true text: "" customHeight: 200 textField.readOnly: true diff --git a/ui/app/AppLayouts/Profile/stores/AdvancedStore.qml b/ui/app/AppLayouts/Profile/stores/AdvancedStore.qml index 30e0528041..9d041d6b0d 100644 --- a/ui/app/AppLayouts/Profile/stores/AdvancedStore.qml +++ b/ui/app/AppLayouts/Profile/stores/AdvancedStore.qml @@ -7,16 +7,16 @@ QtObject { property var advancedModule // Advanced Module Properties - property string currentNetworkName: advancedModule.currentNetworkName - property string currentNetworkId: advancedModule.currentNetworkId - property string fleet: advancedModule.fleet - property string bloomLevel: advancedModule.bloomLevel - property bool wakuV2LightClientEnabled: advancedModule.wakuV2LightClientEnabled - property bool isTelemetryEnabled: advancedModule.isTelemetryEnabled - property bool isAutoMessageEnabled: advancedModule.isAutoMessageEnabled - property bool isDebugEnabled: advancedModule.isDebugEnabled + property string currentNetworkName: advancedModule? advancedModule.currentNetworkName : "" + property string currentNetworkId: advancedModule? advancedModule.currentNetworkId : "" + property string fleet: advancedModule? advancedModule.fleet : "" + property string bloomLevel: advancedModule? advancedModule.bloomLevel : "" + property bool wakuV2LightClientEnabled: advancedModule? advancedModule.wakuV2LightClientEnabled : false + property bool isTelemetryEnabled: advancedModule? advancedModule.isTelemetryEnabled : false + property bool isAutoMessageEnabled: advancedModule? advancedModule.isAutoMessageEnabled : false + property bool isDebugEnabled: advancedModule? advancedModule.isDebugEnabled : false - property var customNetworksModel: advancedModule.customNetworksModel + property var customNetworksModel: advancedModule? advancedModule.customNetworksModel : [] property bool isWakuV2: root.fleet === Constants.waku_prod || root.fleet === Constants.waku_test @@ -33,42 +33,72 @@ QtObject { } function logDir() { + if(!root.advancedModule) + return "" + return root.advancedModule.logDir() } function setNetworkName(networkName) { + if(!root.advancedModule) + return + root.advancedModule.setNetworkName(networkName) } function setFleet(fleetName) { + if(!root.advancedModule) + return + root.advancedModule.setFleet(fleetName) } function setBloomLevel(mode) { + if(!root.advancedModule) + return + root.advancedModule.setBloomLevel(mode) } function setWakuV2LightClientEnabled(mode) { + if(!root.advancedModule) + return + root.advancedModule.setWakuV2LightClientEnabled(mode) } function toggleTelemetry() { + if(!root.advancedModule) + return + root.advancedModule.toggleTelemetry() } function toggleAutoMessage() { + if(!root.advancedModule) + return + root.advancedModule.toggleAutoMessage() } function toggleDebug() { + if(!root.advancedModule) + return + root.advancedModule.toggleDebug() } function addCustomNetwork(name, endpoint, networkId, networkType) { + if(!root.advancedModule) + return + root.advancedModule.addCustomNetwork(name, endpoint, networkId, networkType) } function toggleExperimentalFeature(feature) { + if(!root.advancedModule) + return + if (feature === experimentalFeatures.wallet) { advancedModule.toggleWalletSection() } diff --git a/ui/app/AppLayouts/Profile/views/SoundsView.qml b/ui/app/AppLayouts/Profile/views/SoundsView.qml index 040e3cb7ea..6242c19561 100644 --- a/ui/app/AppLayouts/Profile/views/SoundsView.qml +++ b/ui/app/AppLayouts/Profile/views/SoundsView.qml @@ -43,11 +43,14 @@ Item { anchors.leftMargin: 24 from: 0.0 to: 1.0 - value: localAccountSensitiveSettings.volume stepSize: 0.1 onValueChanged: { localAccountSensitiveSettings.volume = volume.value } + + Component.onCompleted: { + value = localAccountSensitiveSettings.volume + } } } } diff --git a/ui/app/AppLayouts/Wallet/views/RightTabView.qml b/ui/app/AppLayouts/Wallet/views/RightTabView.qml index 505cbebd89..ceec4b0bc4 100644 --- a/ui/app/AppLayouts/Wallet/views/RightTabView.qml +++ b/ui/app/AppLayouts/Wallet/views/RightTabView.qml @@ -24,7 +24,7 @@ Item { locale: RootStore.locale currency: RootStore.currentCurrency currentAccount: RootStore.currentAccount - changeSelectedAccount: changeSelectedAccount + changeSelectedAccount: walletContainer.changeSelectedAccount } RowLayout { diff --git a/ui/app/AppLayouts/WalletV2/panels/WalletHeaderPanel.qml b/ui/app/AppLayouts/WalletV2/panels/WalletHeaderPanel.qml index ef2386b3b6..db3749d175 100644 --- a/ui/app/AppLayouts/WalletV2/panels/WalletHeaderPanel.qml +++ b/ui/app/AppLayouts/WalletV2/panels/WalletHeaderPanel.qml @@ -36,7 +36,7 @@ Item { StyledText { id: title anchors.verticalCenter: parent.verticalCenter - text: walletHeader.currentAccount.name + text: walletHeader.currentAccount? walletHeader.currentAccount.name : "" font.weight: Font.Medium font.pixelSize: 28 } @@ -54,7 +54,7 @@ Item { StyledText { id: walletBalance anchors.verticalCenter: parent.verticalCenter - text: walletHeader.currentAccount.balance.toUpperCase() + text: walletHeader.currentAccount? walletHeader.currentAccount.balance.toUpperCase() : "" font.pixelSize: 22 } } @@ -72,7 +72,7 @@ Item { anchors.top: accountRow.bottom anchors.left: accountRow.left addressWidth: 180 - address: walletHeader.currentAccount.address + address: walletHeader.currentAccount? walletHeader.currentAccount.address : "" } NetworkSelectPanel { diff --git a/ui/app/AppMain.qml b/ui/app/AppMain.qml index e2e4307fe6..8cf51f44f8 100644 --- a/ui/app/AppMain.qml +++ b/ui/app/AppMain.qml @@ -16,6 +16,7 @@ import "./AppLayouts/Chat/popups" import "./AppLayouts/Chat/popups/community" import "./AppLayouts/Profile/popups" import "./AppLayouts/stores" +import "./AppLayouts/Browser/stores" as BrowserStores import Qt.labs.platform 1.1 import Qt.labs.settings 1.0 @@ -150,13 +151,19 @@ Item { Audio { id: sendMessageSound store: rootStore - track: "send_message.wav" + track: Qt.resolvedUrl("../imports/assets/audio/send_message.wav") } Audio { id: notificationSound store: rootStore - track: "notification.wav" + track: Qt.resolvedUrl("../imports/assets/audio/notification.wav") + } + + Audio { + id: errorSound + track: Qt.resolvedUrl("../imports/assets/audio/error.mp3") + store: rootStore } AppSearch{ @@ -470,7 +477,7 @@ Item { // property var _walletModel: walletModel // Not Refactored Yet // property var _utilsModel: utilsModel - property var _web3Provider: web3Provider + property var _web3Provider: BrowserStores.Web3ProviderStore.web3ProviderInst } ProfileLayout { @@ -831,5 +838,6 @@ Item { // console.error('Could not parse the whitelist for sites', e) // } Global.settingsHasLoaded(); + Global.errorSound = errorSound; } } diff --git a/ui/imports/shared/controls/StyledTextArea.qml b/ui/imports/shared/controls/StyledTextArea.qml index 550495be4f..c83ee23d28 100644 --- a/ui/imports/shared/controls/StyledTextArea.qml +++ b/ui/imports/shared/controls/StyledTextArea.qml @@ -24,8 +24,6 @@ Item { id: inputBox height: inputRectangle.height + (hasLabel ? inputLabel.height + labelMargin : 0) + (!!validationError ? validationErrorText.height : 0) - anchors.right: parent.right - anchors.left: parent.left StyledText { id: inputLabel diff --git a/ui/imports/shared/status/StatusChatInput.qml b/ui/imports/shared/status/StatusChatInput.qml index 92088bd57d..453dff3c4b 100644 --- a/ui/imports/shared/status/StatusChatInput.qml +++ b/ui/imports/shared/status/StatusChatInput.qml @@ -853,7 +853,8 @@ Rectangle { anchors.rightMargin: 2 anchors.top: parent.top anchors.topMargin: 2 - stickerData: sticker + // Not Refactored Yet +// stickerData: sticker onCloseButtonClicked: { isReply = false } @@ -941,7 +942,7 @@ Rectangle { icon.name: "bold" //% "Bold" text: qsTrId("bold") - selectedTextWithFormationChars: RootStore.selectedTextWithFormationChars + selectedTextWithFormationChars: RootStore.getSelectedTextWithFormationChars(messageInputField) onActionTriggered: checked ? unwrapSelection(wrapper, RootStore.getSelectedTextWithFormationChars(messageInputField)) : wrapSelection(wrapper) @@ -951,7 +952,7 @@ Rectangle { icon.name: "italic" //% "Italic" text: qsTrId("italic") - selectedTextWithFormationChars: RootStore.selectedTextWithFormationChars + selectedTextWithFormationChars: RootStore.getSelectedTextWithFormationChars(messageInputField) checked: (surroundedBy("*") && !surroundedBy("**")) || surroundedBy("***") onActionTriggered: checked ? unwrapSelection(wrapper, RootStore.getSelectedTextWithFormationChars(messageInputField)) : @@ -962,7 +963,7 @@ Rectangle { icon.name: "strikethrough" //% "Strikethrough" text: qsTrId("strikethrough") - selectedTextWithFormationChars: RootStore.selectedTextWithFormationChars + selectedTextWithFormationChars: RootStore.getSelectedTextWithFormationChars(messageInputField) onActionTriggered: checked ? unwrapSelection(wrapper, RootStore.getSelectedTextWithFormationChars(messageInputField)) : wrapSelection(wrapper) @@ -972,7 +973,7 @@ Rectangle { icon.name: "code" //% "Code" text: qsTrId("code") - selectedTextWithFormationChars: RootStore.selectedTextWithFormationChars + selectedTextWithFormationChars: RootStore.getSelectedTextWithFormationChars(messageInputField) onActionTriggered: checked ? unwrapSelection(wrapper, RootStore.getSelectedTextWithFormationChars(messageInputField)) : wrapSelection(wrapper) diff --git a/ui/imports/shared/status/StatusEmojiSuggestionPopup.qml b/ui/imports/shared/status/StatusEmojiSuggestionPopup.qml index 96f56338ff..57bfac6477 100644 --- a/ui/imports/shared/status/StatusEmojiSuggestionPopup.qml +++ b/ui/imports/shared/status/StatusEmojiSuggestionPopup.qml @@ -9,7 +9,13 @@ import shared 1.0 StatusInputListPopup { id: emojiSuggestions property string shortname - property string unicode: emojiSuggestions.modelList[listView.currentIndex].unicode_alternates || emojiSuggestions.modelList[listView.currentIndex].unicode + property string unicode: { + if(listView.currentIndex < 0 || listView.currentIndex >= emojiSuggestions.modelList.count) + return "" + + return emojiSuggestions.modelList[listView.currentIndex].unicode_alternates || + emojiSuggestions.modelList[listView.currentIndex].unicode + } getImageSource: function (modelData) { return `../../assets/twemoji/72x72/${modelData.unicode}.png` diff --git a/ui/imports/shared/stores/RootStore.qml b/ui/imports/shared/stores/RootStore.qml index 0366a96fc4..a3d1c803cc 100644 --- a/ui/imports/shared/stores/RootStore.qml +++ b/ui/imports/shared/stores/RootStore.qml @@ -4,12 +4,12 @@ import QtQuick 2.12 QtObject { id: root - property var utilsModelInst: !!utilsModel ? utilsModel : null - property var chatsModelInst: !!chatsModel ?chatsModel : null - property var userProfileInst: !!userProfile ? userProfile : null - property var walletModelInst: !!walletModel ? walletModel : null - property var keycardModelInst: !!keycardModel ? keycardModel : null - property var profileModelInst: !!profileModel ? profileModel : null +// property var utilsModelInst: !!utilsModel ? utilsModel : null +// property var chatsModelInst: !!chatsModel ?chatsModel : null +// property var userProfileInst: !!userProfile ? userProfile : null +// property var walletModelInst: !!walletModel ? walletModel : null +// property var keycardModelInst: !!keycardModel ? keycardModel : null +// property var profileModelInst: !!profileModel ? profileModel : null property var walletSectionInst: !!walletSection ? walletSection : null property var appSettings: !!localAppSettings ? localAppSettings : null property var accountSensitiveSettings: !!localAccountSensitiveSettings ? localAccountSensitiveSettings : null @@ -22,13 +22,13 @@ QtObject { property bool displayChatImages: !!accountSensitiveSettings ? accountSensitiveSettings.displayChatImages : false property string locale: !!appSettings ? appSettings.locale : "" - property string signingPhrase: !!walletModelInst ? walletModelInst.utilsView.signingPhrase : "" - property string gasPrice: !!walletModelInst ? walletModelInst.gasView.gasPrice : "0" - property string gasEthValue: !!walletModelInst ? walletModelInst.gasView.getGasEthValue : "0" - property string currentCurrency: !!walletSectionInst ? walletSectionInst.currentCurrency : "" - property string defaultCurrency: !!walletModelInst ? walletModelInst.balanceView.defaultCurrency : "0" - property string fiatValue: !!walletModelInst ? walletModelInst.balanceView.getFiatValue : "0" - property string cryptoValue: !!walletModelInst ? walletModelInst.balanceView.getCryptoValue : "0" +// property string signingPhrase: !!walletModelInst ? walletModelInst.utilsView.signingPhrase : "" +// property string gasPrice: !!walletModelInst ? walletModelInst.gasView.gasPrice : "0" +// property string gasEthValue: !!walletModelInst ? walletModelInst.gasView.getGasEthValue : "0" +// property string currentCurrency: !!walletSectionInst ? walletSectionInst.currentCurrency : "" +// property string defaultCurrency: !!walletModelInst ? walletModelInst.balanceView.defaultCurrency : "0" +// property string fiatValue: !!walletModelInst ? walletModelInst.balanceView.getFiatValue : "0" +// property string cryptoValue: !!walletModelInst ? walletModelInst.balanceView.getCryptoValue : "0" readonly property var formationChars: (["*", "`", "~"]) function getSelectedTextWithFormationChars(messageInputField) { let i = 1 @@ -62,14 +62,14 @@ QtObject { } function transferEth(from, to, amount, gasLimit, gasPrice, tipLimit, overallLimit, password, uuid) { - return walletModelInst.transactionsView.transferEth(from, to, amount, gasLimit, gasPrice, tipLimit, overallLimit, password, uuid); +// return walletModelInst.transactionsView.transferEth(from, to, amount, gasLimit, gasPrice, tipLimit, overallLimit, password, uuid); } function transferTokens(from, to, address, amount, gasLimit, gasPrice, tipLimit, overallLimit, password, uuid) { - return walletModelInst.transactionsView.transferTokens(from, to, address, amount, gasLimit, gasPrice, tipLimit, overallLimit, password, uuid); +// return walletModelInst.transactionsView.transferTokens(from, to, address, amount, gasLimit, gasPrice, tipLimit, overallLimit, password, uuid); } function copyToClipboard(textToCopy) { - chatsModelInst.copyToClipboard(textToCopy) +// chatsModelInst.copyToClipboard(textToCopy) } } diff --git a/ui/imports/utils/Global.qml b/ui/imports/utils/Global.qml index 9ae40693da..b5e6e8f117 100644 --- a/ui/imports/utils/Global.qml +++ b/ui/imports/utils/Global.qml @@ -9,12 +9,9 @@ QtObject { property var applicationWindow property bool popupOpened: false property int currentMenuTab: 0 - property var errorSound: Audio { - id: errorSound - track: Qt.resolvedUrl("../assets/audio/error.mp3") - } + property var errorSound - property var mainModuleInst: !!mainModule ? mainModule : null + property var mainModuleInst property var toastMessage property bool profilePopupOpened: false //Not refactored yet @@ -43,6 +40,9 @@ QtObject { } function changeAppSectionBySectionType(sectionType, profileSectionId = -1) { + if(!root.mainModuleInst) + return + mainModuleInst.setActiveSectionBySectionType(sectionType) if (profileSectionId > -1) { currentMenuTab = profileSectionId; @@ -76,7 +76,8 @@ QtObject { } function playErrorSound() { - errorSound.play(); + if(errorSound) + errorSound.play(); } function settingsHasLoaded() { diff --git a/ui/main.qml b/ui/main.qml index adf8b6f18c..732b4734c4 100644 --- a/ui/main.qml +++ b/ui/main.qml @@ -95,20 +95,25 @@ StatusWindow { Connections { target: startupModule onAppStateChanged: { - mainModule.openStoreToKeychainPopup.connect(function(){ - storeToKeychainConfirmationPopup.open() - }) - if(localAccountSensitiveSettings.recentEmojis === "") { - localAccountSensitiveSettings.recentEmojis = []; - } - if (localAccountSensitiveSettings.whitelistedUnfurlingSites === "") { - localAccountSensitiveSettings.whitelistedUnfurlingSites = {}; - } - if (localAccountSensitiveSettings.hiddenCommunityWelcomeBanners === "") { - localAccountSensitiveSettings.hiddenCommunityWelcomeBanners = []; - } - if (localAccountSensitiveSettings.hiddenCommunityBackUpBanners === "") { - localAccountSensitiveSettings.hiddenCommunityBackUpBanners = []; + if(state === Constants.appState.main) { + // We set main module to the Global singleton once user is logged in and we move to the main app. + Global.mainModuleInst = mainModule + + mainModule.openStoreToKeychainPopup.connect(function(){ + storeToKeychainConfirmationPopup.open() + }) + if(localAccountSensitiveSettings.recentEmojis === "") { + localAccountSensitiveSettings.recentEmojis = []; + } + if (localAccountSensitiveSettings.whitelistedUnfurlingSites === "") { + localAccountSensitiveSettings.whitelistedUnfurlingSites = {}; + } + if (localAccountSensitiveSettings.hiddenCommunityWelcomeBanners === "") { + localAccountSensitiveSettings.hiddenCommunityWelcomeBanners = []; + } + if (localAccountSensitiveSettings.hiddenCommunityBackUpBanners === "") { + localAccountSensitiveSettings.hiddenCommunityBackUpBanners = []; + } } } }