mirror of
https://github.com/TeamPiped/Piped.git
synced 2024-08-30 18:43:17 +00:00
Update from Main
This commit is contained in:
parent
d46ab0f414
commit
4a4f5ae243
39
src/main.js
39
src/main.js
@ -21,7 +21,7 @@ import {
|
|||||||
faServer,
|
faServer,
|
||||||
faDonate,
|
faDonate,
|
||||||
} from "@fortawesome/free-solid-svg-icons";
|
} 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";
|
import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome";
|
||||||
library.add(
|
library.add(
|
||||||
faEye,
|
faEye,
|
||||||
@ -31,6 +31,7 @@ library.add(
|
|||||||
faCheck,
|
faCheck,
|
||||||
faHeart,
|
faHeart,
|
||||||
faHeadphones,
|
faHeadphones,
|
||||||
|
faYoutube,
|
||||||
faRss,
|
faRss,
|
||||||
faChevronLeft,
|
faChevronLeft,
|
||||||
faLevelDownAlt,
|
faLevelDownAlt,
|
||||||
@ -95,7 +96,17 @@ const mixin = {
|
|||||||
return str;
|
return str;
|
||||||
},
|
},
|
||||||
numberFormat(num) {
|
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);
|
return formatter.format(num);
|
||||||
},
|
},
|
||||||
addCommas(num) {
|
addCommas(num) {
|
||||||
@ -114,8 +125,12 @@ const mixin = {
|
|||||||
purifyHTML(original) {
|
purifyHTML(original) {
|
||||||
return DOMPurify.sanitize(original);
|
return DOMPurify.sanitize(original);
|
||||||
},
|
},
|
||||||
setPreference(key, value) {
|
setPreference(key, value, disableAlert = false) {
|
||||||
if (localStorage) localStorage.setItem(key, value);
|
try {
|
||||||
|
localStorage.setItem(key, value);
|
||||||
|
} catch {
|
||||||
|
if (!disableAlert) alert(this.$t("info.local_storage"));
|
||||||
|
}
|
||||||
},
|
},
|
||||||
getPreferenceBoolean(key, defaultVal) {
|
getPreferenceBoolean(key, defaultVal) {
|
||||||
var value;
|
var value;
|
||||||
@ -200,7 +215,11 @@ const mixin = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
getLocalSubscriptions() {
|
getLocalSubscriptions() {
|
||||||
return JSON.parse(localStorage.getItem("localSubscriptions"));
|
try {
|
||||||
|
return JSON.parse(localStorage.getItem("localSubscriptions"));
|
||||||
|
} catch {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
},
|
},
|
||||||
isSubscribedLocally(channelId) {
|
isSubscribedLocally(channelId) {
|
||||||
const localSubscriptions = this.getLocalSubscriptions();
|
const localSubscriptions = this.getLocalSubscriptions();
|
||||||
@ -214,7 +233,13 @@ const mixin = {
|
|||||||
else localSubscriptions.push(channelId);
|
else localSubscriptions.push(channelId);
|
||||||
// Sort for better cache hits
|
// Sort for better cache hits
|
||||||
localSubscriptions.sort();
|
localSubscriptions.sort();
|
||||||
localStorage.setItem("localSubscriptions", JSON.stringify(localSubscriptions));
|
try {
|
||||||
|
localStorage.setItem("localSubscriptions", JSON.stringify(localSubscriptions));
|
||||||
|
return true;
|
||||||
|
} catch {
|
||||||
|
alert(this.$t("info.local_storage"));
|
||||||
|
}
|
||||||
|
return false;
|
||||||
},
|
},
|
||||||
getUnauthenticatedChannels() {
|
getUnauthenticatedChannels() {
|
||||||
const localSubscriptions = this.getLocalSubscriptions() ?? [];
|
const localSubscriptions = this.getLocalSubscriptions() ?? [];
|
||||||
@ -244,7 +269,7 @@ const mixin = {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async defaultLangage() {
|
async defaultLanguage() {
|
||||||
const languages = window.navigator.languages;
|
const languages = window.navigator.languages;
|
||||||
for (let i = 0; i < languages.length; i++) {
|
for (let i = 0; i < languages.length; i++) {
|
||||||
try {
|
try {
|
||||||
|
Loading…
Reference in New Issue
Block a user