mirror of
https://github.com/TeamPiped/Piped.git
synced 2026-11-09 20:17:17 +00:00
unauthenticated subscriptions (#1270)
* hmm * unauthenticated feed * unauthenticated rss * Small improvements to code. * add unauthenticated subscriptions * cleanup * Sort subs locally. * Fix some bugs and small improvements. Co-authored-by: Kavin <20838718+FireMasterK@users.noreply.github.com>
This commit is contained in:
@@ -14,7 +14,6 @@
|
||||
</p>
|
||||
|
||||
<button
|
||||
v-if="authenticated"
|
||||
class="btn"
|
||||
@click="subscribeHandler"
|
||||
v-t="{
|
||||
@@ -50,7 +49,7 @@ export default {
|
||||
data() {
|
||||
return {
|
||||
channel: null,
|
||||
subscribed: false,
|
||||
subscribed: this.authenticated ? false : this.isSubscribedLocally(this.channelId),
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
@@ -69,6 +68,8 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
async fetchSubscribedStatus() {
|
||||
if (!this.channelId || !this.authenticated) return;
|
||||
|
||||
this.fetchJson(
|
||||
this.authApiUrl() + "/subscribed",
|
||||
{
|
||||
@@ -113,16 +114,20 @@ export default {
|
||||
}
|
||||
},
|
||||
subscribeHandler() {
|
||||
this.fetchJson(this.authApiUrl() + (this.subscribed ? "/unsubscribe" : "/subscribe"), null, {
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
channelId: this.channel.id,
|
||||
}),
|
||||
headers: {
|
||||
Authorization: this.getAuthToken(),
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
});
|
||||
if (this.authenticated) {
|
||||
this.fetchJson(this.authApiUrl() + (this.subscribed ? "/unsubscribe" : "/subscribe"), null, {
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
channelId: this.channel.id,
|
||||
}),
|
||||
headers: {
|
||||
Authorization: this.getAuthToken(),
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
});
|
||||
} else {
|
||||
this.handleLocalSubscriptions(this.channel.id);
|
||||
}
|
||||
this.subscribed = !this.subscribed;
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user