From e0cf9e61826045c4b0699e88336bf9990db3f852 Mon Sep 17 00:00:00 2001 From: Kavin <20838718+FireMasterK@users.noreply.github.com> Date: Mon, 1 Aug 2022 21:59:49 +0530 Subject: [PATCH] Fix unsubscribe button in subscriptions page. Only affects when unauthenticated. --- src/components/SubscriptionsPage.vue | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/components/SubscriptionsPage.vue b/src/components/SubscriptionsPage.vue index 4d7affaf..50c452a7 100644 --- a/src/components/SubscriptionsPage.vue +++ b/src/components/SubscriptionsPage.vue @@ -63,16 +63,21 @@ export default { } }, handleButton(subscription) { - this.fetchJson(this.authApiUrl() + (subscription.subscribed ? "/unsubscribe" : "/subscribe"), null, { - method: "POST", - body: JSON.stringify({ - channelId: subscription.url.split("/")[2], - }), - headers: { - Authorization: this.getAuthToken(), - "Content-Type": "application/json", - }, - }); + const channelId = subscription.url.split("/")[2]; + if (this.authenticated) { + this.fetchJson(this.authApiUrl() + (subscription.subscribed ? "/unsubscribe" : "/subscribe"), null, { + method: "POST", + body: JSON.stringify({ + channelId: channelId, + }), + headers: { + Authorization: this.getAuthToken(), + "Content-Type": "application/json", + }, + }); + } else { + this.handleLocalSubscriptions(channelId); + } subscription.subscribed = !subscription.subscribed; }, exportHandler() {