Login and subscriptions. (#256)

* WIP login and subscriptions.

* Add a working feed and unsubscribe button.

* Allow importing subscriptions from Google Takeout, NewPipe and Invidious.
This commit is contained in:
FireMasterK
2021-07-17 04:26:41 +05:30
committed by GitHub
parent 4cb06c3569
commit 0992e1e96d
10 changed files with 448 additions and 1 deletions

View File

@@ -34,6 +34,14 @@ import App from "./App.vue";
import DOMPurify from "dompurify";
import TimeAgo from "javascript-time-ago";
import en from "javascript-time-ago/locale/en";
TimeAgo.addDefaultLocale(en);
const timeAgo = new TimeAgo("en-US");
import("./registerServiceWorker");
const mixin = {
@@ -136,6 +144,18 @@ const mixin = {
window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
return theme;
},
getAuthToken() {
return this.getPreferenceString("authToken" + this.hashCode(this.apiUrl()));
},
hashCode(s) {
return s.split("").reduce(function(a, b) {
a = (a << 5) - a + b.charCodeAt(0);
return a & a;
}, 0);
},
timeAgo(time) {
return timeAgo.format(time);
},
},
computed: {
backgroundColor() {
@@ -153,6 +173,9 @@ const mixin = {
darkMode() {
return this.getEffectiveTheme() !== "light";
},
authenticated(_this) {
return _this.getAuthToken() !== undefined;
},
},
};