mirror of
https://github.com/TeamPiped/Piped.git
synced 2026-09-15 17:23:45 +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:
@@ -69,7 +69,6 @@ export default {
|
||||
},
|
||||
},
|
||||
activated() {
|
||||
if (!this.authenticated) this.$router.push("/login");
|
||||
document.title = "Import - Piped";
|
||||
},
|
||||
methods: {
|
||||
@@ -132,21 +131,34 @@ export default {
|
||||
});
|
||||
},
|
||||
handleImport() {
|
||||
this.fetchJson(
|
||||
this.authApiUrl() + "/import",
|
||||
{
|
||||
override: this.override,
|
||||
},
|
||||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: this.getAuthToken(),
|
||||
if (this.authenticated) {
|
||||
this.fetchJson(
|
||||
this.authApiUrl() + "/import",
|
||||
{
|
||||
override: this.override,
|
||||
},
|
||||
body: JSON.stringify(this.subscriptions),
|
||||
},
|
||||
).then(json => {
|
||||
if (json.message === "ok") window.location = "/feed";
|
||||
});
|
||||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: this.getAuthToken(),
|
||||
},
|
||||
body: JSON.stringify(this.subscriptions),
|
||||
},
|
||||
).then(json => {
|
||||
if (json.message === "ok") window.location = "/feed";
|
||||
});
|
||||
} else {
|
||||
this.importSubscriptionsLocally(this.subscriptions);
|
||||
window.location = "/feed";
|
||||
}
|
||||
},
|
||||
importSubscriptionsLocally(newChannels) {
|
||||
const subscriptions = this.override
|
||||
? [...new Set(newChannels)]
|
||||
: [...new Set(this.getLocalSubscriptions().concat(newChannels))];
|
||||
// Sort for better cache hits
|
||||
subscriptions.sort();
|
||||
localStorage.setItem("localSubscriptions", JSON.stringify(subscriptions));
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user