diff --git a/ui/imports/shared/popups/addaccount/AddAccountPopup.qml b/ui/imports/shared/popups/addaccount/AddAccountPopup.qml index 88349ea325..d7b4ae9a68 100644 --- a/ui/imports/shared/popups/addaccount/AddAccountPopup.qml +++ b/ui/imports/shared/popups/addaccount/AddAccountPopup.qml @@ -20,12 +20,6 @@ StatusModal { property AddAccountStore store: AddAccountStore { } - enum LimitWarning { - Accounts, - Keypairs, - WatchOnlyAccounts - } - width: Constants.addAccountPopup.popupWidth closePolicy: root.store.disablePopup? Popup.NoAutoClose : Popup.CloseOnEscape | Popup.CloseOnPressOutside @@ -74,13 +68,13 @@ StatusModal { property string content function showPopup(warningType) { - if (warningType === AddAccountPopup.LimitWarning.Accounts) { + if (warningType === Constants.LimitWarning.Accounts) { limitPopup.title = Constants.walletConstants.maxNumberOfAccountsTitle limitPopup.content = Constants.walletConstants.maxNumberOfAccountsContent - } else if (warningType === AddAccountPopup.LimitWarning.Keypairs) { + } else if (warningType === Constants.LimitWarning.Keypairs) { limitPopup.title = Constants.walletConstants.maxNumberOfKeypairsTitle limitPopup.content = Constants.walletConstants.maxNumberOfKeypairsContent - } else if (warningType === AddAccountPopup.LimitWarning.WatchOnlyAccounts) { + } else if (warningType === Constants.LimitWarning.WatchOnlyAccounts) { limitPopup.title = Constants.walletConstants.maxNumberOfWatchOnlyAccountsTitle limitPopup.content = Constants.walletConstants.maxNumberOfSavedAddressesContent } else { @@ -158,10 +152,10 @@ StatusModal { store: root.store onWatchOnlyAccountsLimitReached: { - limitPopup.showPopup(AddAccountPopup.LimitWarning.WatchOnlyAccounts) + limitPopup.showPopup(Constants.LimitWarning.WatchOnlyAccounts) } onKeypairLimitReached: { - limitPopup.showPopup(AddAccountPopup.LimitWarning.Keypairs) + limitPopup.showPopup(Constants.LimitWarning.Keypairs) } } } diff --git a/ui/imports/shared/popups/addaccount/states/Main.qml b/ui/imports/shared/popups/addaccount/states/Main.qml index 982209e78b..dd6918f262 100644 --- a/ui/imports/shared/popups/addaccount/states/Main.qml +++ b/ui/imports/shared/popups/addaccount/states/Main.qml @@ -9,8 +9,6 @@ import StatusQ.Controls 0.1 import StatusQ.Controls.Validators 0.1 import utils 1.0 -import StatusQ 0.1 -import SortFilterProxyModel 0.2 import "../stores" import "../panels" @@ -55,20 +53,6 @@ Item { id: d readonly property bool isEdit: root.store.editMode - readonly property SortFilterProxyModel originModelWithoutWatchOnlyAcc: SortFilterProxyModel { - id: originModelWithoutWatchOnlyAcc - objectName: "originModelWithoutWatchOnlyAcc" - sourceModel: root.store.originModel - - readonly property string addWatchOnlyAccKeyUid: Constants.appTranslatableConstants.addAccountLabelOptionAddWatchOnlyAcc - filters: [ - FastExpressionFilter { - expression: model.keyPair.keyUid !== originModelWithoutWatchOnlyAcc.addWatchOnlyAccKeyUid - expectedRoles: ["keyPair"] - } - ] - } - function openEmojiPopup(showLeft) { if (!root.store.emojiPopup) { return @@ -191,7 +175,7 @@ Item { anchors.horizontalCenter: parent.horizontalCenter userProfilePublicKey: root.store.userProfilePublicKey - originModel: root.store.editMode? [] : d.originModelWithoutWatchOnlyAcc + originModel: root.store.editMode? [] : root.store.originModel selectedOrigin: root.store.selectedOrigin caretVisible: !root.store.editMode enabled: !root.store.editMode diff --git a/ui/imports/shared/popups/addaccount/stores/AddAccountStore.qml b/ui/imports/shared/popups/addaccount/stores/AddAccountStore.qml index 6490246f55..53814ce14c 100644 --- a/ui/imports/shared/popups/addaccount/stores/AddAccountStore.qml +++ b/ui/imports/shared/popups/addaccount/stores/AddAccountStore.qml @@ -54,6 +54,9 @@ BasePopupStore { Constants.addAccountPopup.predefinedPaths.ethereumLedgerLive ] + readonly property bool isWatchOnlyImport: root.selectedOrigin.pairType === Constants.addAccountPopup.keyPairType.unknown && + root.selectedOrigin.keyUid === Constants.appTranslatableConstants.addAccountLabelOptionAddWatchOnlyAcc + signal showLimitPopup(int warningType) signal resolvedENS(string resolvedPubKey, string resolvedAddress, string uuid) @@ -97,23 +100,31 @@ BasePopupStore { return } - if(!event) { - if (!root.editMode && root.remainingAccountCapacity() === 0) { - root.showLimitPopup(0) - return - } - - root.currentState.doPrimaryAction() + const handleEvent = !event || event.key === Qt.Key_Return || event.key === Qt.Key_Enter + if (!handleEvent) { + return } - else if (event.key === Qt.Key_Return || event.key === Qt.Key_Enter) { + + if (handleEvent && !!event) { event.accepted = true - if (!root.editMode && root.remainingAccountCapacity() === 0) { - root.showLimitPopup(0) - return - } - - root.currentState.doPrimaryAction() } + + if (root.editMode) { + root.currentState.doPrimaryAction() + return + } + + if (root.isWatchOnlyImport && root.remainingWatchOnlyAccountCapacity() === 0) { + root.showLimitPopup(Constants.LimitWarning.WatchOnlyAccounts) + return + } + + if (root.remainingAccountCapacity() === 0) { + root.showLimitPopup(Constants.LimitWarning.Accounts) + return + } + + root.currentState.doPrimaryAction() } function getSeedPhrase() { diff --git a/ui/imports/utils/Constants.qml b/ui/imports/utils/Constants.qml index 5c60dfe00f..7204367ff4 100644 --- a/ui/imports/utils/Constants.qml +++ b/ui/imports/utils/Constants.qml @@ -1434,4 +1434,10 @@ QtObject { Theme.svg("walletconnect"), Theme.png("status-logo") ] + + enum LimitWarning { + Accounts, + Keypairs, + WatchOnlyAccounts + } }