mirror of
https://github.com/TeamPiped/Piped.git
synced 2025-12-25 14:10:21 +00:00
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:
23
src/main.js
23
src/main.js
@@ -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;
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user