Update blue_modules/currency.ts

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
This commit is contained in:
Marcos Rodriguez Vélez 2024-10-26 22:33:14 -04:00 committed by GitHub
parent a7550df576
commit 5570c124cd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -62,11 +62,16 @@ async function updateExchangeRate(): Promise<void> {
}
} else {
// Handle unexpected errors without alerting the user
const rate = JSON.parse((await AsyncStorage.getItem(EXCHANGE_RATES_STORAGE_KEY)) || '{}');
rate.LAST_UPDATED_ERROR = true;
exchangeRates.LAST_UPDATED_ERROR = true;
await AsyncStorage.setItem(EXCHANGE_RATES_STORAGE_KEY, JSON.stringify(rate));
}
try {
const rate = JSON.parse((await AsyncStorage.getItem(EXCHANGE_RATES_STORAGE_KEY)) || '{}');
rate.LAST_UPDATED_ERROR = true;
exchangeRates.LAST_UPDATED_ERROR = true;
await AsyncStorage.setItem(EXCHANGE_RATES_STORAGE_KEY, JSON.stringify(rate));
} catch (parseError) {
console.error('Failed to parse exchange rates from storage', parseError);
exchangeRates.LAST_UPDATED_ERROR = true;
await AsyncStorage.removeItem(EXCHANGE_RATES_STORAGE_KEY);
}
}
}