mirror of
https://github.com/TeamPiped/Piped.git
synced 2024-12-23 14:03:35 +00:00
Use getPreference* instead of accessing localStorage directly
This commit is contained in:
parent
d980edd843
commit
7b832a981c
@ -502,8 +502,8 @@ export default {
|
|||||||
this.selectedAuthInstance = this.getPreferenceString("auth_instance_url", this.selectedInstance);
|
this.selectedAuthInstance = this.getPreferenceString("auth_instance_url", this.selectedInstance);
|
||||||
|
|
||||||
this.sponsorBlock = this.getPreferenceBoolean("sponsorblock", true);
|
this.sponsorBlock = this.getPreferenceBoolean("sponsorblock", true);
|
||||||
if (localStorage.getItem("skipOptions") !== null) {
|
var skipOptions, skipList;
|
||||||
const skipOptions = JSON.parse(localStorage.getItem("skipOptions"));
|
if ((skipOptions = this.getPreferenceJSON("skipOptions")) !== null) {
|
||||||
if (skipOptions.sponsor !== undefined) this.skipSponsor = skipOptions.sponsor;
|
if (skipOptions.sponsor !== undefined) this.skipSponsor = skipOptions.sponsor;
|
||||||
if (skipOptions.intro !== undefined) this.skipIntro = skipOptions.intro;
|
if (skipOptions.intro !== undefined) this.skipIntro = skipOptions.intro;
|
||||||
if (skipOptions.outro !== undefined) this.skipOutro = skipOptions.outro;
|
if (skipOptions.outro !== undefined) this.skipOutro = skipOptions.outro;
|
||||||
@ -513,8 +513,8 @@ export default {
|
|||||||
if (skipOptions.music_offtopic !== undefined) this.skipMusicOffTopic = skipOptions.music_offtopic;
|
if (skipOptions.music_offtopic !== undefined) this.skipMusicOffTopic = skipOptions.music_offtopic;
|
||||||
if (skipOptions.poi_highlight !== undefined) this.skipHighlight = skipOptions.poi_highlight;
|
if (skipOptions.poi_highlight !== undefined) this.skipHighlight = skipOptions.poi_highlight;
|
||||||
if (skipOptions.filler !== undefined) this.skipFiller = skipOptions.filler;
|
if (skipOptions.filler !== undefined) this.skipFiller = skipOptions.filler;
|
||||||
} else if (localStorage.getItem("selectedSkip") !== null) {
|
} else if ((skipList = this.getPreferenceString("selectedSkip")) !== null) {
|
||||||
var skipList = localStorage.getItem("selectedSkip").split(",");
|
skipList = skipList.split(",");
|
||||||
this.skipSponsor =
|
this.skipSponsor =
|
||||||
this.skipIntro =
|
this.skipIntro =
|
||||||
this.skipOutro =
|
this.skipOutro =
|
||||||
@ -562,7 +562,7 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.showMarkers = this.getPreferenceBoolean("showMarkers", true);
|
this.showMarkers = this.getPreferenceBoolean("showMarkers", true);
|
||||||
this.minSegmentLength = Math.max(Number(localStorage.getItem("minSegmentLength")), 0);
|
this.minSegmentLength = Math.max(this.getPreferenceNumber("minSegmentLength", 0), 0);
|
||||||
this.selectedTheme = this.getPreferenceString("theme", "dark");
|
this.selectedTheme = this.getPreferenceString("theme", "dark");
|
||||||
this.autoPlayVideo = this.getPreferenceBoolean("playerAutoPlay", true);
|
this.autoPlayVideo = this.getPreferenceBoolean("playerAutoPlay", true);
|
||||||
this.listen = this.getPreferenceBoolean("listen", false);
|
this.listen = this.getPreferenceBoolean("listen", false);
|
||||||
|
@ -750,7 +750,7 @@ export default {
|
|||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
sponsors() {
|
sponsors() {
|
||||||
const skipOptions = JSON.parse(this.getPreferenceString("skipOptions", "{}"));
|
const skipOptions = this.getPreferenceJSON("skipOptions", {});
|
||||||
this.sponsors?.segments?.forEach(segment => {
|
this.sponsors?.segments?.forEach(segment => {
|
||||||
const option = skipOptions[segment.category];
|
const option = skipOptions[segment.category];
|
||||||
segment.autoskip = option === undefined || option === "auto";
|
segment.autoskip = option === undefined || option === "auto";
|
||||||
|
@ -371,9 +371,8 @@ export default {
|
|||||||
"selectedSkip",
|
"selectedSkip",
|
||||||
"sponsor,interaction,selfpromo,music_offtopic",
|
"sponsor,interaction,selfpromo,music_offtopic",
|
||||||
).split(",");
|
).split(",");
|
||||||
const skipOptionsJSON = localStorage.getItem("skipOptions");
|
const skipOptions = this.getPreferenceJSON("skipOptions");
|
||||||
if (skipOptionsJSON !== null) {
|
if (skipOptions !== null) {
|
||||||
const skipOptions = JSON.parse(skipOptionsJSON);
|
|
||||||
selectedSkip = Object.keys(skipOptions).filter(
|
selectedSkip = Object.keys(skipOptions).filter(
|
||||||
k => skipOptions[k] !== undefined && skipOptions[k] !== "no",
|
k => skipOptions[k] !== undefined && skipOptions[k] !== "no",
|
||||||
);
|
);
|
||||||
|
@ -162,6 +162,15 @@ const mixin = {
|
|||||||
return Number(value);
|
return Number(value);
|
||||||
} else return defaultVal;
|
} else return defaultVal;
|
||||||
},
|
},
|
||||||
|
getPreferenceJSON(key, defaultVal) {
|
||||||
|
var value;
|
||||||
|
if (
|
||||||
|
(value = new URLSearchParams(window.location.search).get(key)) !== null ||
|
||||||
|
(this.testLocalStorage && (value = localStorage.getItem(key)) !== null)
|
||||||
|
) {
|
||||||
|
return JSON.parse(value);
|
||||||
|
} else return defaultVal;
|
||||||
|
},
|
||||||
apiUrl() {
|
apiUrl() {
|
||||||
return this.getPreferenceString("instance", "https://pipedapi.kavin.rocks");
|
return this.getPreferenceString("instance", "https://pipedapi.kavin.rocks");
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user