Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into dashboard_tab
Browse files Browse the repository at this point in the history
  • Loading branch information
Duddino committed Sep 27, 2023
2 parents f470f3b + 2a42b60 commit 10f53fc
Show file tree
Hide file tree
Showing 15 changed files with 44 additions and 53 deletions.
2 changes: 1 addition & 1 deletion locale/de/translation.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const de_translation = {
export default {
// This document is to be used as a template as all the base code is in English
// Basic HTML tags are allowed such as <b><i> etc. All data is sanitized https://developer.mozilla.org/en-US/docs/Web/API/Element/innerHTML

Expand Down
2 changes: 1 addition & 1 deletion locale/en/translation.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const en_translation = {
export default {
// This document is to be used as a template as all the base code is in English
// Basic HTML tags are allowed such as <b><i> etc. All data is sanitized https://developer.mozilla.org/en-US/docs/Web/API/Element/innerHTML

Expand Down
2 changes: 1 addition & 1 deletion locale/es-mx/translation.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const es_mx_translation = {
export default {
// Este documento se debe usar como una plantilla ya que todo el código base está en inglés
// Se permiten etiquetas HTML básicas como <b><i> etc. Todos los datos están saneados https://developer.mozilla.org/es/docs/Web/API/Element/innerHTML

Expand Down
2 changes: 1 addition & 1 deletion locale/fr/translation.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const fr_translation = {
export default {
// Les balises HTML de base sont autorisées, comme <b><i>, etc. Toutes les données sont nettoyées https://developer.mozilla.org/fr/docs/Web/API/Element/innerHTML

// NOTA: Si une section n'a PAS besoin d'être traduite, laissez-la vide..
Expand Down
2 changes: 1 addition & 1 deletion locale/it/translation.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const it_translation = {
export default {
// Sono consentiti tag HTML di base, come <b><i> ecc. Tutti i dati vengono puliti https://developer.mozilla.org/fr/docs/Web/API/Element/innerHTML

// NOTA: Se una sezione NON necessita di traduzione , lasciala vuota.
Expand Down
2 changes: 1 addition & 1 deletion locale/ph/translation.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const ph_translation = {
export default {
// This document is to be used as a template as all the base code is in English
// Basic HTML tags are allowed such as <b><i> etc. All data is sanitized https://developer.mozilla.org/en-US/docs/Web/API/Element/innerHTML

Expand Down
2 changes: 1 addition & 1 deletion locale/pt-br/translation.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const pt_br_translation = {
export default {
// As tags básicas HTML são permitidas como <b><i> etc. Todos os dados são higienizados https://developer.mozilla.org/pt-BR/docs/Web/API/Element/innerHTML

// NOTA: Se uma seção NÃO precisar ser traduzida, deixe-a vazia.
Expand Down
2 changes: 1 addition & 1 deletion locale/pt-pt/translation.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const pt_pt_translation = {
export default {
// As tags básicas HTML são permitidas como <b><i> etc. Todos os dados são higienizados https://developer.mozilla.org/pt-BR/docs/Web/API/Element/innerHTML

// NOTA: Se uma seção NÃO precisar ser traduzida, deixe-a vazia.
Expand Down
2 changes: 1 addition & 1 deletion locale/template/translation.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const translation_template = {
export default {
// This document is to be used as a template as all the base code is in English
// Basic HTML tags are allowed such as <b><i> etc. All data is sanitized https://developer.mozilla.org/en-US/docs/Web/API/Element/innerHTML

Expand Down
2 changes: 1 addition & 1 deletion locale/uwu/translation.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const uwu_translation = {
export default {
// Basic HTML tags are allowed such as <b><i> etc. All data is sanitized https://developer.mozilla.org/en-US/docs/Web/API/Element/innerHTML

// NOTE: If a section does NOT need translating, leave it empty.
Expand Down
23 changes: 14 additions & 9 deletions scripts/global.js
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,18 @@ function subscribeToNetworkEvents() {
}
});

getEventEmitter().on('new-block', (block, oldBlock) => {
console.log(`New block detected! ${oldBlock} --> ${block}`);
// Fetch latest Activity
activityDashboard.update(true);
stakingDashboard.update(true);

// If it's open: update the Governance Dashboard
if (doms.domGovTab.classList.contains('active')) {
updateGovernanceTab();
}
});

getEventEmitter().on('transaction-sent', (success, result) => {
if (success) {
doms.domAddress1s.value = '';
Expand Down Expand Up @@ -2545,15 +2557,8 @@ export async function refreshChainData() {
);
if (!wallet.isLoaded()) return;

// Fetch block count + UTXOs, update the UI for new transactions
await cNet.getBlockCount();
// Fetch latest Activity
activityDashboard.update(true);

// If it's open: update the Governance Dashboard
if (doms.domGovTab.classList.contains('active')) {
updateGovernanceTab();
}
// Fetch block count
cNet.getBlockCount().then(() => {});
}

// A safety mechanism enabled if the user attempts to leave without encrypting/saving their keys
Expand Down
39 changes: 12 additions & 27 deletions scripts/i18n.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
import { translation_template } from '../locale/template/translation.js';
import { en_translation } from '../locale/en/translation.js';
import { pt_br_translation } from '../locale/pt-br/translation.js';
import { pt_pt_translation } from '../locale/pt-pt/translation.js';
import { es_mx_translation } from '../locale/es-mx/translation.js';
import { ph_translation } from '../locale/ph/translation.js';
import { uwu_translation } from '../locale/uwu/translation.js';
import { fr_translation } from '../locale/fr/translation.js';
import { it_translation } from '../locale/it/translation.js';
import { de_translation } from '../locale/de/translation.js';
import { Database } from './database.js';
import { fillAnalyticSelect, setTranslation } from './settings.js';
import { updateEncryptionGUI } from './global.js';
Expand All @@ -26,32 +17,28 @@ export const ALERTS = {};
*/
export const translation = reactive({});

// TRANSLATION
//Create an object of objects filled with all the translations
export const translatableLanguages = {
en: en_translation,
uwu: uwu_translation,
'pt-pt': pt_pt_translation,
'pt-br': pt_br_translation,
'es-mx': es_mx_translation,
ph: ph_translation,
fr: fr_translation,
it: it_translation,
de: de_translation,
};
/**
* @param {string} code
* @returns {Promise<translation_template>}
*/
async function getLanguage(code) {
return (await import(`../locale/${code}/translation.js`)).default;
}

/**
* Takes the language name and sets the translation settings based on the language file
* @param {string} langName
*/
export function switchTranslation(langName) {
export async function switchTranslation(langName) {
if (arrActiveLangs.find((lang) => lang.code === langName)) {
// Load every 'active' key of the language, otherwise, we'll default the key to the EN file
const arrNewLang = translatableLanguages[langName];
const arrNewLang = await getLanguage(langName);
for (const strKey of Object.keys(arrNewLang)) {
// Skip empty and/or missing i18n keys, defaulting them to EN
if (!arrNewLang[strKey]) {
translation[strKey] = translatableLanguages.en[strKey];
// It's fine if we import a language multiple times
// Webpack will fetch it once from the server
translation[strKey] = (await getLanguage('en'))[strKey];
continue;
}

Expand Down Expand Up @@ -155,7 +142,6 @@ function parseUserAgentLang(strUA, arrLangsWithSubset) {
return strUA;
}

// When adding a lang remember to add it to the object translatableLanguages as well as here.
export const arrActiveLangs = [
{ code: 'en', emoji: '🇬🇧' },
{ code: 'fr', emoji: '🇫🇷' },
Expand All @@ -180,7 +166,6 @@ export async function start() {
? parseUserAgentLang(localeLang.toLowerCase(), arrLangsWithSubset)
: undefined;

// When removing you do not have to remove from translatableLanguages
const database = await Database.getInstance();
const { translation: localTranslation } = await database.getSettings();

Expand Down
10 changes: 5 additions & 5 deletions scripts/network.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,11 +215,10 @@ export class ExplorerNetwork extends Network {
await retryWrapper(fetchBlockbook, `/api/v2/api`)
).json();
if (backend.blocks > this.blocks) {
console.log(
'New block detected! ' +
this.blocks +
' --> ' +
backend.blocks
getEventEmitter().emit(
'new-block',
backend.blocks,
this.blocks
);
this.blocks = backend.blocks;

Expand All @@ -231,6 +230,7 @@ export class ExplorerNetwork extends Network {
} finally {
getEventEmitter().emit('sync-status', 'stop');
}
return this.blocks;
}

/**
Expand Down
3 changes: 2 additions & 1 deletion scripts/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
} from './i18n.js';
import { CoinGecko, refreshPriceDisplay } from './prices.js';
import { Database } from './database.js';
import { getEventEmitter } from './event_bus';

// --- Default Settings
/** A mode that emits verbose console info for internal MPW operations */
Expand Down Expand Up @@ -326,7 +327,7 @@ async function setCurrency(currency) {
const database = await Database.getInstance();
database.setSettings({ displayCurrency: strCurrency });
// Update the UI to reflect the new currency
getBalance(true);
getEventEmitter().emit('balance-update');
getStakingBalance(true);
}

Expand Down
2 changes: 1 addition & 1 deletion scripts/wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ export class Wallet {
this.#addressIndex =
this.#addressIndex > last ? this.#addressIndex : last;
if (this.isHD()) {
for (let i = 0; i < this.#addressIndex; i++) {
for (let i = 0; i <= this.#addressIndex + MAX_ACCOUNT_GAP; i++) {
const path = this.getDerivationPath(0, i);
const testAddress = await this.#masterKey.getAddress(path);
if (address === testAddress) {
Expand Down

0 comments on commit 10f53fc

Please sign in to comment.