Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't show "Your wallet is verified!" when reconnecting after a natural disconnect. #9738

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ void Uphold::DisconnectWallet(const std::string& notification) {
}
const auto to = wallet->status;

LogWalletStatusChange(ledger_, from, to);
OnWalletStatusChange(ledger_, from, to);

const bool shutting_down = ledger_->IsShuttingDown();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ void UpholdAuthorization::OnAuthorize(
return callback(type::Result::LEDGER_ERROR, {});
}

LogWalletStatusChange(ledger_, from, to);
OnWalletStatusChange(ledger_, from, to);

callback(type::Result::LEDGER_OK, {});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
namespace ledger {
namespace uphold {

namespace {
bool g_show_newly_verified_wallet = true;
} // namespace

std::string GetClientId() {
return ledger::_environment == type::Environment::PRODUCTION
? UPHOLD_CLIENT_ID
Expand Down Expand Up @@ -187,9 +191,9 @@ bool one_of(T&& t, Ts&&... ts) {
return match;
}

void LogWalletStatusChange(LedgerImpl* ledger,
absl::optional<type::WalletStatus> from,
type::WalletStatus to) {
void OnWalletStatusChange(LedgerImpl* ledger,
absl::optional<type::WalletStatus> from,
type::WalletStatus to) {
DCHECK(ledger);
DCHECK(!from ||
one_of(*from, type::WalletStatus::NOT_CONNECTED,
Expand All @@ -206,6 +210,15 @@ void LogWalletStatusChange(LedgerImpl* ledger,
oss << "==> " << to;

ledger->database()->SaveEventLog(log::kWalletStatusChange, oss.str());

if (to == type::WalletStatus::PENDING) {
DCHECK(from);
g_show_newly_verified_wallet = *from == type::WalletStatus::NOT_CONNECTED;
}
}

bool ShouldShowNewlyVerifiedWallet() {
return g_show_newly_verified_wallet;
}

} // namespace uphold
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,11 @@ type::ExternalWalletPtr GenerateLinks(type::ExternalWalletPtr wallet);

std::string GenerateVerifyLink(type::ExternalWalletPtr wallet);

void LogWalletStatusChange(LedgerImpl* ledger,
absl::optional<type::WalletStatus> from,
type::WalletStatus to);
void OnWalletStatusChange(LedgerImpl* ledger,
absl::optional<type::WalletStatus> from,
type::WalletStatus to);

bool ShouldShowNewlyVerifiedWallet();

} // namespace uphold
} // namespace ledger
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ void UpholdWallet::Generate(ledger::ResultCallback callback) const {
return callback(type::Result::LEDGER_ERROR);
}

LogWalletStatusChange(ledger_, {}, uphold_wallet->status);
OnWalletStatusChange(ledger_, {}, uphold_wallet->status);
}

if (uphold_wallet->one_time_string.empty()) {
Expand Down Expand Up @@ -297,15 +297,17 @@ void UpholdWallet::OnLinkWallet(const type::Result result,
return callback(type::Result::LEDGER_ERROR);
}

LogWalletStatusChange(ledger_, from, to);
OnWalletStatusChange(ledger_, from, to);

ledger_->database()->SaveEventLog(
log::kWalletVerified,
constant::kWalletUphold + std::string("/") + id.substr(0, 5));

ledger_->ledger_client()->ShowNotification(
ledger::notifications::kWalletNewVerified, {"Uphold"},
[](type::Result) {});
if (ShouldShowNewlyVerifiedWallet()) {
ledger_->ledger_client()->ShowNotification(
ledger::notifications::kWalletNewVerified, {"Uphold"},
[](type::Result) {});
}

ledger_->promotion()->TransferTokens(
std::bind(&UpholdWallet::OnTransferTokens, this, _1, _2, callback));
Expand Down