This commit is contained in:
Bnyro 2022-08-01 14:56:58 +02:00
parent 5650752fcf
commit de4d8ce350

View file

@ -40,28 +40,28 @@ export default {
}; };
}, },
mounted() { mounted() {
if (this.authenticated) this.fetchSubscriptions().then(json => {
this.fetchJson(this.authApiUrl() + "/subscriptions", null, {
headers: {
Authorization: this.getAuthToken(),
},
}).then(json => {
this.subscriptions = json; this.subscriptions = json;
this.subscriptions.forEach(subscription => (subscription.subscribed = true)); this.subscriptions.forEach(subscription => (subscription.subscribed = true));
}); });
else {
this.fetchJson(this.authApiUrl() + "/subscriptions/unauthenticated", null, {
channels: this.getUnauthenticatedChannels(),
}).then(json => {
this.subscriptions = json;
this.subscriptions.forEach(subscription => (subscription.subscribed = true));
});
}
}, },
activated() { activated() {
document.title = "Subscriptions - Piped"; document.title = "Subscriptions - Piped";
}, },
methods: { methods: {
async fetchSubscriptions() {
if (this.authenticated) {
return await this.fetchJson(this.authApiUrl() + "/subscriptions", null, {
headers: {
Authorization: this.getAuthToken(),
},
});
} else {
return await this.fetchJson(this.authApiUrl() + "/subscriptions/unauthenticated", null, {
channels: this.getUnauthenticatedChannels(),
});
}
},
handleButton(subscription) { handleButton(subscription) {
this.fetchJson(this.authApiUrl() + (subscription.subscribed ? "/unsubscribe" : "/subscribe"), null, { this.fetchJson(this.authApiUrl() + (subscription.subscribed ? "/unsubscribe" : "/subscribe"), null, {
method: "POST", method: "POST",