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

Fix CoinGecko spam (finally) #129

Merged
merged 2 commits into from
May 11, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 2 additions & 4 deletions scripts/global.js
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,9 @@ export function start() {

const publicKey = localStorage.getItem('publicKey');

// Import the wallet, and toggle the startup flag, which delegates the chain data refresh to settingsStart();
if (publicKey) {
importWallet({ newWif: publicKey });
importWallet({ newWif: publicKey, fStartup: true });
} else {
// Display the password unlock upfront
accessOrImportWallet();
Expand Down Expand Up @@ -340,9 +341,6 @@ export function start() {
refreshPriceDisplay();
}, 15000);

// Initial price fetch
refreshPriceDisplay();

// After reaching here; we know MPW's base is fully loaded!
fIsLoaded = true;
}
Expand Down
7 changes: 4 additions & 3 deletions scripts/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
doms,
getBalance,
getStakingBalance,
refreshChainData,
updateStakingRewardsGUI,
} from './global.js';
import { fWalletLoaded, masterKey } from './wallet.js';
Expand All @@ -14,7 +15,7 @@ import {
translation,
arrActiveLangs,
} from './i18n.js';
import { CoinGecko } from './prices.js';
import { CoinGecko, refreshPriceDisplay } from './prices.js';

// --- Default Settings
/** A mode that emits verbose console info for internal MPW operations */
Expand Down Expand Up @@ -100,9 +101,9 @@ export function start() {
fillNodeSelect();
fillTranslationSelect();

// Fill all selection UIs with their options
// Fetch price data, then fetch chain data
if (getNetwork().enabled) {
fillCurrencySelect();
refreshPriceDisplay().finally(refreshChainData);
}

// Add each analytics level into the UI selector
Expand Down
6 changes: 4 additions & 2 deletions scripts/wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,7 @@ export function deriveAddress({ pkBytes, publicKey, output = 'ENCODED' }) {
* @param {boolean} options.isHardwareWallet - Whether the import is from a Hardware wallet or not
* @param {boolean} options.skipConfirmation - Whether to skip the import UI confirmation or not
* @param {boolean} options.fSavePublicKey - Whether to save the derived public key to disk (for View Only mode)
* @param {boolean} options.fStartup - Whether the import is at Startup or at Runtime
* @returns {Promise<void>}
*/
export async function importWallet({
Expand All @@ -496,6 +497,7 @@ export async function importWallet({
isHardwareWallet = false,
skipConfirmation = false,
fSavePublicKey = false,
fStartup = false,
} = {}) {
const strImportConfirm =
"Do you really want to import a new address? If you haven't saved the last private key, the wallet will be LOST forever.";
Expand Down Expand Up @@ -656,8 +658,8 @@ export async function importWallet({
}
}

// Fetch state from explorer
if (getNetwork().enabled) refreshChainData();
// Fetch state from explorer, if this import was post-startup
if (getNetwork().enabled && !fStartup) refreshChainData();

// Hide all wallet starter options
hideAllWalletOptions();
Expand Down