Skip to content
Open
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
4 changes: 2 additions & 2 deletions app/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -481,8 +481,8 @@
"zecprice": "ZEC Price",
"unknown": "Unknown",
"title": "Server Info",
"errorgemini": "Error fetching the price from the Internet.",
"errorrpcmodule": "Internal Error fetching the price from the Internet",
"errorgemini": "Could not fetch the price from the Internet.",
"errorrpcmodule": "The price arrived in a form the app could not read.",
"zingolib": "Zingolib Version"
},
"rescan": {
Expand Down
4 changes: 2 additions & 2 deletions app/translations/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -481,8 +481,8 @@
"zecprice": "Precio del ZEC",
"unknown": "Desconocido",
"title": "Informaci贸n del Servidor",
"errorgemini": "Error extrayendo el precio de Internet.",
"errorrpcmodule": "Fallo interno al obtener el precio de Internet",
"errorgemini": "No se pudo obtener el precio de Internet.",
"errorrpcmodule": "El precio lleg贸 en un formato que la aplicaci贸n no pudo leer.",
"zingolib": "Versi贸n de Zingolib"
},
"rescan": {
Expand Down
4 changes: 2 additions & 2 deletions app/translations/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -481,8 +481,8 @@
"zecprice": "Pre莽o do ZEC",
"unknown": "Desconhecido",
"title": "Informa莽玫es do Servidor",
"errorgemini": "Error ao buscar o pre莽o na Internet.",
"errorrpcmodule": "Erro interno ao buscar o pre莽o na Internet",
"errorgemini": "N茫o foi poss铆vel obter o pre莽o na Internet.",
"errorrpcmodule": "O pre莽o chegou num formato que a aplica莽茫o n茫o conseguiu ler.",
"zingolib": "Vers茫o Zingolib"
},
"rescan": {
Expand Down
4 changes: 2 additions & 2 deletions app/translations/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -481,8 +481,8 @@
"zecprice": "笑械薪邪 ZEC",
"unknown": "袧械懈蟹胁械褋褌薪芯",
"title": "袛邪薪薪褘械 褋械褉胁械褉邪",
"errorgemini": "Error 锌褉懈 锌芯谢褍褔械薪懈懈 褑械薪褘 懈蟹 袠薪褌械褉薪械褌邪.",
"errorrpcmodule": "袙薪褍褌褉械薪薪褟褟 芯褕懈斜泻邪 锌芯谢褍褔械薪懈褟 褑械薪褘 懈蟹 袠薪褌械褉薪械褌邪",
"errorgemini": "袧械 褍写邪谢芯褋褜 锌芯谢褍褔懈褌褜 褑械薪褍 懈蟹 袠薪褌械褉薪械褌邪.",
"errorrpcmodule": "笑械薪邪 锌褉懈褕谢邪 胁 胁懈写械, 泻芯褌芯褉褘泄 锌褉懈谢芯卸械薪懈械 薪械 褋屑芯谐谢芯 锌褉芯褔懈褌邪褌褜.",
"zingolib": "袙械褉褋懈褟 Zingolib"
},
"rescan": {
Expand Down
4 changes: 2 additions & 2 deletions app/translations/tr.json
Original file line number Diff line number Diff line change
Expand Up @@ -481,8 +481,8 @@
"zecprice": "ZEC Fiyat谋 ",
"unknown": "Bilinmeyen ",
"title": "Sunucu Bilgisi",
"errorgemini": "Error 陌nternetten fiyat al谋n谋rken hata olu艧tu.",
"errorrpcmodule": "陌nternetten fiyat al谋n谋rken i莽 hata olu艧tu ",
"errorgemini": "Fiyat 陌nternet'ten al谋namad谋.",
"errorrpcmodule": "Fiyat, uygulaman谋n okuyamad谋臒谋 bir bi莽imde geldi.",
"zingolib": "Zingolib S眉r眉m眉"
},
"rescan": {
Expand Down
49 changes: 27 additions & 22 deletions components/Components/priceFetcherStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function scheduleAuto(): void {
clearAuto();
if (listeners.size === 0 || !started) return;
autoTimer = setTimeout(() => {
doFetch().catch(() => {});
doFetch();
}, PRICE_AUTO_REFRESH_MS);
}

Expand All @@ -74,28 +74,33 @@ async function doFetch(): Promise<void> {
if (cooldownTimer) clearTimeout(cooldownTimer);
cooldownTimer = setTimeout(emit, COOLDOWN_MS);

const outcome = await getZecPrice();
if (outcome.kind === 'error') {
// A failed refresh leaves the last good price on screen. Overwriting it
// would trade a stale number for no number at all.
const detail = outcome.param === undefined ? '' : ` - ${outcome.param}`;
d.addLastSnackbar(`${d.translate(outcome.errorKey) as string}${detail}`);
} else {
d.setZecPrice(outcome.usd, Date.now());
started = true;
}
try {
const outcome = await getZecPrice();
if (outcome.kind === 'error') {
// A failed refresh leaves the last good price on screen. Overwriting it
// would trade a stale number for no number at all.
const detail = outcome.param === undefined ? '' : ` - ${outcome.param}`;
d.addLastSnackbar(`${d.translate(outcome.errorKey) as string}${detail}`);
} else {
d.setZecPrice(outcome.usd, Date.now());
started = true;
}

// Floor the visible loading time so the CTA/ring state doesn't flash by.
const elapsed = Date.now() - now;
if (elapsed < MIN_VISIBLE_MS) {
await new Promise<void>(resolve =>
setTimeout(resolve, MIN_VISIBLE_MS - elapsed),
);
// Floor the visible loading time so the CTA/ring state doesn't flash by.
const elapsed = Date.now() - now;
if (elapsed < MIN_VISIBLE_MS) {
await new Promise<void>(resolve =>
setTimeout(resolve, MIN_VISIBLE_MS - elapsed),
);
}
} finally {
// The three injected callbacks above belong to the host screen and can
// throw. Leaving `loading` set would strand every later fetch at the gate
// while the ring kept spinning against a loop that had stopped.
loading = false;
emit();
scheduleAuto();
}

loading = false;
emit();
scheduleAuto();
}

export const priceFetcherStore = {
Expand All @@ -105,7 +110,7 @@ export const priceFetcherStore = {
},
/** User- or timer-initiated fetch. No-ops while loading / cooling down. */
fetch(): void {
doFetch().catch(() => {});
doFetch();
},
hasStarted(): boolean {
return started;
Expand Down
Loading