Fix unsubscribe button in subscriptions page.

Only affects when unauthenticated.
This commit is contained in:
Kavin 2022-08-01 21:59:49 +05:30
parent c51a3a828e
commit e0cf9e6182
No known key found for this signature in database
GPG Key ID: 49451E4482CC5BCD

View File

@ -63,16 +63,21 @@ export default {
} }
}, },
handleButton(subscription) { handleButton(subscription) {
const channelId = subscription.url.split("/")[2];
if (this.authenticated) {
this.fetchJson(this.authApiUrl() + (subscription.subscribed ? "/unsubscribe" : "/subscribe"), null, { this.fetchJson(this.authApiUrl() + (subscription.subscribed ? "/unsubscribe" : "/subscribe"), null, {
method: "POST", method: "POST",
body: JSON.stringify({ body: JSON.stringify({
channelId: subscription.url.split("/")[2], channelId: channelId,
}), }),
headers: { headers: {
Authorization: this.getAuthToken(), Authorization: this.getAuthToken(),
"Content-Type": "application/json", "Content-Type": "application/json",
}, },
}); });
} else {
this.handleLocalSubscriptions(channelId);
}
subscription.subscribed = !subscription.subscribed; subscription.subscribed = !subscription.subscribed;
}, },
exportHandler() { exportHandler() {