Keep existing address selected in recieve dropdown

This commit is contained in:
Aditya Kulkarni
2019-07-27 08:00:11 -07:00
parent f7f641972d
commit c4a691381d

View File

@@ -1258,6 +1258,9 @@ std::function<void(bool)> MainWindow::addZAddrsToComboList(bool sapling) {
return [=] (bool checked) {
if (checked && this->rpc->getAllZAddresses() != nullptr) {
auto addrs = this->rpc->getAllZAddresses();
// Save the current address, so we can update it later
auto zaddr = ui->listReceiveAddresses->currentText();
ui->listReceiveAddresses->clear();
std::for_each(addrs->begin(), addrs->end(), [=] (auto addr) {
@@ -1269,6 +1272,10 @@ std::function<void(bool)> MainWindow::addZAddrsToComboList(bool sapling) {
}
}
});
if (!zaddr.isEmpty() && Settings::isZAddress(zaddr)) {
ui->listReceiveAddresses->setCurrentText(zaddr);
}
// If z-addrs are empty, then create a new one.
if (addrs->isEmpty()) {
@@ -1461,6 +1468,10 @@ void MainWindow::setupReceiveTab() {
void MainWindow::updateTAddrCombo(bool checked) {
if (checked) {
auto utxos = this->rpc->getUTXOs();
// Save the current address so we can restore it later
auto currentTaddr = ui->listReceiveAddresses->currentText();
ui->listReceiveAddresses->clear();
// Maintain a set of addresses so we don't duplicate any, because we'll be adding
@@ -1502,6 +1513,16 @@ void MainWindow::updateTAddrCombo(bool checked) {
ui->listReceiveAddresses->addItem(addr, 0);
}
}
// 4. Add the previously selected t-address
if (!currentTaddr.isEmpty() && Settings::isTAddress(currentTaddr)) {
// Make sure the current taddr is in the list
if (!addrs.contains(currentTaddr)) {
auto bal = rpc->getAllBalances()->value(currentTaddr);
ui->listReceiveAddresses->addItem(currentTaddr, bal);
}
ui->listReceiveAddresses->setCurrentText(currentTaddr);
}
}
};