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:
Bnyro
2022-08-01 16:16:06 +02:00
committed by GitHub
parent 1ebf153814
commit c51a3a828e
7 changed files with 118 additions and 64 deletions

View File

@@ -80,7 +80,6 @@
</button>
<button
class="btn"
v-if="authenticated"
@click="subscribeHandler"
v-t="{
path: `actions.${subscribed ? 'unsubscribe' : 'subscribe'}`,
@@ -427,7 +426,8 @@ export default {
this.fetchComments().then(data => (this.comments = data));
},
async fetchSubscribedStatus() {
if (!this.channelId || !this.authenticated) return;
if (!this.channelId) return;
if (!this.authenticated) this.subscribed = this.isSubscribedLocally(this.channelId);
this.fetchJson(
this.authApiUrl() + "/subscribed",
@@ -444,16 +444,20 @@ export default {
});
},
subscribeHandler() {
this.fetchJson(this.authApiUrl() + (this.subscribed ? "/unsubscribe" : "/subscribe"), null, {
method: "POST",
body: JSON.stringify({
channelId: this.channelId,
}),
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.channelId,
}),
headers: {
Authorization: this.getAuthToken(),
"Content-Type": "application/json",
},
});
} else {
this.handleLocalSubscriptions(this.channelId);
}
this.subscribed = !this.subscribed;
},
handleScroll() {