Try catch for NumberFormat.

See https://github.com/TeamPiped/Piped/pull/1675#issuecomment-1302587072
This commit is contained in:
Kavin 2022-11-03 19:54:00 +00:00
parent 99c4d65864
commit 7ac0940bd5
No known key found for this signature in database
GPG Key ID: 49451E4482CC5BCD

View File

@ -88,12 +88,17 @@ const mixin = {
return str; return str;
}, },
numberFormat(num) { numberFormat(num) {
const formatter = Intl.NumberFormat( var loc = `${this.getPreferenceString("hl")}-${this.getPreferenceString("region")}`;
`${this.getPreferenceString("hl")}-${this.getPreferenceString("region")}`,
{ try {
notation: "compact", Intl.getCanonicalLocales(loc);
}, } catch {
); loc = undefined;
}
const formatter = Intl.NumberFormat(loc, {
notation: "compact",
});
return formatter.format(num); return formatter.format(num);
}, },
addCommas(num) { addCommas(num) {