mirror of
https://github.com/TeamPiped/Piped.git
synced 2024-08-14 23:57:27 +00:00
add unauthenticated subscriptions
This commit is contained in:
parent
f18388c828
commit
45a0b0a179
4 changed files with 40 additions and 26 deletions
|
@ -1,7 +1,7 @@
|
|||
<template>
|
||||
<h1 v-t="'titles.feed'" class="font-bold text-center my-4" />
|
||||
|
||||
<button v-if="authenticated" class="btn mr-2" @click="exportHandler">
|
||||
<button class="btn mr-2" @click="exportHandler">
|
||||
<router-link to="/subscriptions">Subscriptions</router-link>
|
||||
</button>
|
||||
|
||||
|
@ -85,15 +85,6 @@ export default {
|
|||
this.loadMoreVideos();
|
||||
}
|
||||
},
|
||||
getUnauthenticatedChannels() {
|
||||
const localSubscriptions = this.getLocalSubscriptions();
|
||||
var channels = "";
|
||||
localSubscriptions.forEach((element, index) => {
|
||||
channels += element;
|
||||
if (localSubscriptions.size != index) channels += ",";
|
||||
});
|
||||
return channels;
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
|
|
@ -69,7 +69,6 @@ export default {
|
|||
},
|
||||
},
|
||||
activated() {
|
||||
if (!this.authenticated) this.$router.push("/login");
|
||||
document.title = "Import - Piped";
|
||||
},
|
||||
methods: {
|
||||
|
@ -132,6 +131,7 @@ export default {
|
|||
});
|
||||
},
|
||||
handleImport() {
|
||||
if (this.authenticated) {
|
||||
this.fetchJson(
|
||||
this.authApiUrl() + "/import",
|
||||
{
|
||||
|
@ -147,6 +147,9 @@ export default {
|
|||
).then(json => {
|
||||
if (json.message === "ok") window.location = "/feed";
|
||||
});
|
||||
} else {
|
||||
this.importSubscriptionsLocally(this.subscriptions);
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
|
|
|
@ -49,7 +49,14 @@ export default {
|
|||
this.subscriptions = json;
|
||||
this.subscriptions.forEach(subscription => (subscription.subscribed = true));
|
||||
});
|
||||
else this.$router.push("/login");
|
||||
else {
|
||||
this.fetchJson(this.authApiUrl() + "/subscriptions/unauthenticated", null, {
|
||||
channels: this.getUnauthenticatedChannels(),
|
||||
}).then(json => {
|
||||
this.subscriptions = json;
|
||||
this.subscriptions.forEach(subscription => (subscription.subscribed = true));
|
||||
});
|
||||
}
|
||||
},
|
||||
activated() {
|
||||
document.title = "Subscriptions - Piped";
|
||||
|
|
13
src/main.js
13
src/main.js
|
@ -215,6 +215,19 @@ const mixin = {
|
|||
else localSubscriptions.push(channelId);
|
||||
localStorage.setItem("localSubscriptions", JSON.stringify(localSubscriptions));
|
||||
},
|
||||
getUnauthenticatedChannels() {
|
||||
const localSubscriptions = this.getLocalSubscriptions();
|
||||
var channels = "";
|
||||
localSubscriptions.forEach((element, index) => {
|
||||
channels += element;
|
||||
if (localSubscriptions.size != index) channels += ",";
|
||||
});
|
||||
return channels;
|
||||
},
|
||||
importSubscriptionsLocally(newChannels) {
|
||||
const subscriptions = this.getLocalSubscriptions().concat(newChannels);
|
||||
localStorage.setItem("localSubscriptions"), JSON.stringify(subscriptions);
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
theme() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue