mirror of
https://github.com/TeamPiped/Piped.git
synced 2026-03-16 05:27:01 +00:00
Add better error messages for localStorage disabled.
This commit is contained in:
20
src/main.js
20
src/main.js
@@ -119,7 +119,11 @@ const mixin = {
|
||||
return DOMPurify.sanitize(original);
|
||||
},
|
||||
setPreference(key, value) {
|
||||
if (localStorage) localStorage.setItem(key, value);
|
||||
try {
|
||||
localStorage.setItem(key, value);
|
||||
} catch {
|
||||
alert(this.$t("info.local_storage"));
|
||||
}
|
||||
},
|
||||
getPreferenceBoolean(key, defaultVal) {
|
||||
var value;
|
||||
@@ -204,7 +208,11 @@ const mixin = {
|
||||
}
|
||||
},
|
||||
getLocalSubscriptions() {
|
||||
return JSON.parse(localStorage.getItem("localSubscriptions"));
|
||||
try {
|
||||
return JSON.parse(localStorage.getItem("localSubscriptions"));
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
},
|
||||
isSubscribedLocally(channelId) {
|
||||
const localSubscriptions = this.getLocalSubscriptions();
|
||||
@@ -218,7 +226,13 @@ const mixin = {
|
||||
else localSubscriptions.push(channelId);
|
||||
// Sort for better cache hits
|
||||
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() {
|
||||
const localSubscriptions = this.getLocalSubscriptions() ?? [];
|
||||
|
||||
Reference in New Issue
Block a user