Update from Main

This commit is contained in:
Dragos 2022-12-18 13:04:29 +02:00 committed by GitHub
parent d46ab0f414
commit 4a4f5ae243
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -21,7 +21,7 @@ import {
faServer,
faDonate,
} from "@fortawesome/free-solid-svg-icons";
import { faGithub, faBitcoin } from "@fortawesome/free-brands-svg-icons";
import { faGithub, faBitcoin, faYoutube } from "@fortawesome/free-brands-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome";
library.add(
faEye,
@ -31,6 +31,7 @@ library.add(
faCheck,
faHeart,
faHeadphones,
faYoutube,
faRss,
faChevronLeft,
faLevelDownAlt,
@ -95,7 +96,17 @@ const mixin = {
return str;
},
numberFormat(num) {
const formatter = Intl.NumberFormat(undefined, { notation: "compact" });
var loc = `${this.getPreferenceString("hl")}-${this.getPreferenceString("region")}`;
try {
Intl.getCanonicalLocales(loc);
} catch {
loc = undefined;
}
const formatter = Intl.NumberFormat(loc, {
notation: "compact",
});
return formatter.format(num);
},
addCommas(num) {
@ -114,8 +125,12 @@ const mixin = {
purifyHTML(original) {
return DOMPurify.sanitize(original);
},
setPreference(key, value) {
if (localStorage) localStorage.setItem(key, value);
setPreference(key, value, disableAlert = false) {
try {
localStorage.setItem(key, value);
} catch {
if (!disableAlert) alert(this.$t("info.local_storage"));
}
},
getPreferenceBoolean(key, defaultVal) {
var value;
@ -200,7 +215,11 @@ const mixin = {
}
},
getLocalSubscriptions() {
try {
return JSON.parse(localStorage.getItem("localSubscriptions"));
} catch {
return [];
}
},
isSubscribedLocally(channelId) {
const localSubscriptions = this.getLocalSubscriptions();
@ -214,7 +233,13 @@ const mixin = {
else localSubscriptions.push(channelId);
// Sort for better cache hits
localSubscriptions.sort();
try {
localStorage.setItem("localSubscriptions", JSON.stringify(localSubscriptions));
return true;
} catch {
alert(this.$t("info.local_storage"));
}
return false;
},
getUnauthenticatedChannels() {
const localSubscriptions = this.getLocalSubscriptions() ?? [];
@ -244,7 +269,7 @@ const mixin = {
return false;
}
},
async defaultLangage() {
async defaultLanguage() {
const languages = window.navigator.languages;
for (let i = 0; i < languages.length; i++) {
try {