|
@@ -53,8 +53,6 @@ app.use(VueTippy, {
|
|
defaultProps: { animation: "scale", touch: "hold" }
|
|
defaultProps: { animation: "scale", touch: "hold" }
|
|
});
|
|
});
|
|
|
|
|
|
-app.use(createPinia());
|
|
|
|
-
|
|
|
|
app.component("Tippy", Tippy);
|
|
app.component("Tippy", Tippy);
|
|
|
|
|
|
app.component("PageMetadata", {
|
|
app.component("PageMetadata", {
|
|
@@ -247,84 +245,87 @@ const router = createRouter({
|
|
]
|
|
]
|
|
});
|
|
});
|
|
|
|
|
|
-const userAuthStore = useUserAuthStore();
|
|
|
|
-const modalsStore = useModalsStore();
|
|
|
|
-
|
|
|
|
-router.beforeEach((to, from, next) => {
|
|
|
|
- if (window.stationInterval) {
|
|
|
|
- clearInterval(window.stationInterval);
|
|
|
|
- window.stationInterval = 0;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // if (to.name === "station") {
|
|
|
|
- // modalsStore.closeModal("manageStation");
|
|
|
|
- // }
|
|
|
|
|
|
+app.use(createPinia());
|
|
|
|
|
|
- modalsStore.closeAllModals();
|
|
|
|
|
|
+const { createSocket } = useWebsocketsStore();
|
|
|
|
+createSocket().then(async socket => {
|
|
|
|
+ const userAuthStore = useUserAuthStore();
|
|
|
|
+ const modalsStore = useModalsStore();
|
|
|
|
|
|
- const { socket } = useWebsocketsStore();
|
|
|
|
|
|
+ router.beforeEach((to, from, next) => {
|
|
|
|
+ if (window.stationInterval) {
|
|
|
|
+ clearInterval(window.stationInterval);
|
|
|
|
+ window.stationInterval = 0;
|
|
|
|
+ }
|
|
|
|
|
|
- if (socket.ready && to.fullPath !== from.fullPath) {
|
|
|
|
- socket.clearCallbacks();
|
|
|
|
- socket.destroyListeners();
|
|
|
|
- }
|
|
|
|
|
|
+ // if (to.name === "station") {
|
|
|
|
+ // modalsStore.closeModal("manageStation");
|
|
|
|
+ // }
|
|
|
|
|
|
- if (to.query.toast) {
|
|
|
|
- const toast =
|
|
|
|
- typeof to.query.toast === "string"
|
|
|
|
- ? { content: to.query.toast, timeout: 20000 }
|
|
|
|
- : to.query.toast;
|
|
|
|
- new Toast(toast);
|
|
|
|
- const { query } = to;
|
|
|
|
- delete query.toast;
|
|
|
|
- next({ ...to, query });
|
|
|
|
- } else if (
|
|
|
|
- to.meta.loginRequired ||
|
|
|
|
- to.meta.permissionRequired ||
|
|
|
|
- to.meta.guestsOnly
|
|
|
|
- ) {
|
|
|
|
- const gotData = () => {
|
|
|
|
- if (to.meta.loginRequired && !userAuthStore.loggedIn)
|
|
|
|
- next({ path: "/login" });
|
|
|
|
- else if (
|
|
|
|
- to.meta.permissionRequired &&
|
|
|
|
- !userAuthStore.hasPermission(to.meta.permissionRequired)
|
|
|
|
- )
|
|
|
|
- next({ path: "/" });
|
|
|
|
- else if (to.meta.guestsOnly && userAuthStore.loggedIn)
|
|
|
|
- next({ path: "/" });
|
|
|
|
- else next();
|
|
|
|
- };
|
|
|
|
|
|
+ modalsStore.closeAllModals();
|
|
|
|
|
|
- if (userAuthStore.gotData && userAuthStore.gotPermissions) gotData();
|
|
|
|
- else {
|
|
|
|
- const unsubscribe = userAuthStore.$onAction(
|
|
|
|
- ({ name, after, onError }) => {
|
|
|
|
- if (name === "authData" || name === "updatePermissions") {
|
|
|
|
- after(() => {
|
|
|
|
- if (
|
|
|
|
- userAuthStore.gotData &&
|
|
|
|
- userAuthStore.gotPermissions
|
|
|
|
- )
|
|
|
|
- gotData();
|
|
|
|
- unsubscribe();
|
|
|
|
- });
|
|
|
|
-
|
|
|
|
- onError(() => {
|
|
|
|
- unsubscribe();
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- );
|
|
|
|
|
|
+ if (socket.ready && to.fullPath !== from.fullPath) {
|
|
|
|
+ socket.clearCallbacks();
|
|
|
|
+ socket.destroyListeners();
|
|
}
|
|
}
|
|
- } else next();
|
|
|
|
-});
|
|
|
|
|
|
|
|
-app.use(router);
|
|
|
|
|
|
+ if (to.query.toast) {
|
|
|
|
+ const toast =
|
|
|
|
+ typeof to.query.toast === "string"
|
|
|
|
+ ? { content: to.query.toast, timeout: 20000 }
|
|
|
|
+ : to.query.toast;
|
|
|
|
+ new Toast(toast);
|
|
|
|
+ const { query } = to;
|
|
|
|
+ delete query.toast;
|
|
|
|
+ next({ ...to, query });
|
|
|
|
+ } else if (
|
|
|
|
+ to.meta.loginRequired ||
|
|
|
|
+ to.meta.permissionRequired ||
|
|
|
|
+ to.meta.guestsOnly
|
|
|
|
+ ) {
|
|
|
|
+ const gotData = () => {
|
|
|
|
+ if (to.meta.loginRequired && !userAuthStore.loggedIn)
|
|
|
|
+ next({ path: "/login" });
|
|
|
|
+ else if (
|
|
|
|
+ to.meta.permissionRequired &&
|
|
|
|
+ !userAuthStore.hasPermission(to.meta.permissionRequired)
|
|
|
|
+ )
|
|
|
|
+ next({ path: "/" });
|
|
|
|
+ else if (to.meta.guestsOnly && userAuthStore.loggedIn)
|
|
|
|
+ next({ path: "/" });
|
|
|
|
+ else next();
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ if (userAuthStore.gotData && userAuthStore.gotPermissions)
|
|
|
|
+ gotData();
|
|
|
|
+ else {
|
|
|
|
+ const unsubscribe = userAuthStore.$onAction(
|
|
|
|
+ ({ name, after, onError }) => {
|
|
|
|
+ if (
|
|
|
|
+ name === "authData" ||
|
|
|
|
+ name === "updatePermissions"
|
|
|
|
+ ) {
|
|
|
|
+ after(() => {
|
|
|
|
+ if (
|
|
|
|
+ userAuthStore.gotData &&
|
|
|
|
+ userAuthStore.gotPermissions
|
|
|
|
+ )
|
|
|
|
+ gotData();
|
|
|
|
+ unsubscribe();
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ onError(() => {
|
|
|
|
+ unsubscribe();
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
+ } else next();
|
|
|
|
+ });
|
|
|
|
|
|
-lofig.folder = defaultConfigURL;
|
|
|
|
|
|
+ app.use(router);
|
|
|
|
|
|
-(async () => {
|
|
|
|
lofig.fetchConfig().then(config => {
|
|
lofig.fetchConfig().then(config => {
|
|
const { configVersion, skipConfigVersionCheck } = config;
|
|
const { configVersion, skipConfigVersionCheck } = config;
|
|
if (
|
|
if (
|
|
@@ -339,77 +340,74 @@ lofig.folder = defaultConfigURL;
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
|
|
- const { createSocket } = useWebsocketsStore();
|
|
|
|
- createSocket().then(socket => {
|
|
|
|
- socket.on("ready", res => {
|
|
|
|
- const { loggedIn, role, username, userId, email } = res.data;
|
|
|
|
-
|
|
|
|
- userAuthStore.authData({
|
|
|
|
- loggedIn,
|
|
|
|
- role,
|
|
|
|
- username,
|
|
|
|
- email,
|
|
|
|
- userId
|
|
|
|
- });
|
|
|
|
|
|
+ socket.on("ready", res => {
|
|
|
|
+ const { loggedIn, role, username, userId, email } = res.data;
|
|
|
|
+
|
|
|
|
+ userAuthStore.authData({
|
|
|
|
+ loggedIn,
|
|
|
|
+ role,
|
|
|
|
+ username,
|
|
|
|
+ email,
|
|
|
|
+ userId
|
|
});
|
|
});
|
|
|
|
+ });
|
|
|
|
|
|
- socket.on("keep.event:user.banned", res =>
|
|
|
|
- userAuthStore.banUser(res.data.ban)
|
|
|
|
- );
|
|
|
|
|
|
+ socket.on("keep.event:user.banned", res =>
|
|
|
|
+ userAuthStore.banUser(res.data.ban)
|
|
|
|
+ );
|
|
|
|
|
|
- socket.on("keep.event:user.username.updated", res =>
|
|
|
|
- userAuthStore.updateUsername(res.data.username)
|
|
|
|
- );
|
|
|
|
|
|
+ socket.on("keep.event:user.username.updated", res =>
|
|
|
|
+ userAuthStore.updateUsername(res.data.username)
|
|
|
|
+ );
|
|
|
|
|
|
- socket.on("keep.event:user.preferences.updated", res => {
|
|
|
|
- const { preferences } = res.data;
|
|
|
|
|
|
+ socket.on("keep.event:user.preferences.updated", res => {
|
|
|
|
+ const { preferences } = res.data;
|
|
|
|
|
|
- const {
|
|
|
|
- changeAutoSkipDisliked,
|
|
|
|
- changeNightmode,
|
|
|
|
- changeActivityLogPublic,
|
|
|
|
- changeAnonymousSongRequests,
|
|
|
|
- changeActivityWatch
|
|
|
|
- } = useUserPreferencesStore();
|
|
|
|
|
|
+ const {
|
|
|
|
+ changeAutoSkipDisliked,
|
|
|
|
+ changeNightmode,
|
|
|
|
+ changeActivityLogPublic,
|
|
|
|
+ changeAnonymousSongRequests,
|
|
|
|
+ changeActivityWatch
|
|
|
|
+ } = useUserPreferencesStore();
|
|
|
|
|
|
- if (preferences.autoSkipDisliked !== undefined)
|
|
|
|
- changeAutoSkipDisliked(preferences.autoSkipDisliked);
|
|
|
|
|
|
+ if (preferences.autoSkipDisliked !== undefined)
|
|
|
|
+ changeAutoSkipDisliked(preferences.autoSkipDisliked);
|
|
|
|
|
|
- if (preferences.nightmode !== undefined) {
|
|
|
|
- localStorage.setItem("nightmode", preferences.nightmode);
|
|
|
|
- changeNightmode(preferences.nightmode);
|
|
|
|
- }
|
|
|
|
|
|
+ if (preferences.nightmode !== undefined) {
|
|
|
|
+ localStorage.setItem("nightmode", preferences.nightmode);
|
|
|
|
+ changeNightmode(preferences.nightmode);
|
|
|
|
+ }
|
|
|
|
|
|
- if (preferences.activityLogPublic !== undefined)
|
|
|
|
- changeActivityLogPublic(preferences.activityLogPublic);
|
|
|
|
|
|
+ if (preferences.activityLogPublic !== undefined)
|
|
|
|
+ changeActivityLogPublic(preferences.activityLogPublic);
|
|
|
|
|
|
- if (preferences.anonymousSongRequests !== undefined)
|
|
|
|
- changeAnonymousSongRequests(preferences.anonymousSongRequests);
|
|
|
|
|
|
+ if (preferences.anonymousSongRequests !== undefined)
|
|
|
|
+ changeAnonymousSongRequests(preferences.anonymousSongRequests);
|
|
|
|
|
|
- if (preferences.activityWatch !== undefined)
|
|
|
|
- changeActivityWatch(preferences.activityWatch);
|
|
|
|
- });
|
|
|
|
|
|
+ if (preferences.activityWatch !== undefined)
|
|
|
|
+ changeActivityWatch(preferences.activityWatch);
|
|
|
|
+ });
|
|
|
|
|
|
- socket.on("keep.event:user.role.updated", res => {
|
|
|
|
- userAuthStore.updateRole(res.data.role);
|
|
|
|
- userAuthStore.updatePermissions().then(() => {
|
|
|
|
- const { meta } = router.currentRoute.value;
|
|
|
|
- if (
|
|
|
|
- meta &&
|
|
|
|
- meta.permissionRequired &&
|
|
|
|
- !userAuthStore.hasPermission(meta.permissionRequired)
|
|
|
|
- )
|
|
|
|
- router.push({
|
|
|
|
- path: "/",
|
|
|
|
- query: {
|
|
|
|
- toast: "You no longer have access to the page you were viewing."
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- });
|
|
|
|
|
|
+ socket.on("keep.event:user.role.updated", res => {
|
|
|
|
+ userAuthStore.updateRole(res.data.role);
|
|
|
|
+ userAuthStore.updatePermissions().then(() => {
|
|
|
|
+ const { meta } = router.currentRoute.value;
|
|
|
|
+ if (
|
|
|
|
+ meta &&
|
|
|
|
+ meta.permissionRequired &&
|
|
|
|
+ !userAuthStore.hasPermission(meta.permissionRequired)
|
|
|
|
+ )
|
|
|
|
+ router.push({
|
|
|
|
+ path: "/",
|
|
|
|
+ query: {
|
|
|
|
+ toast: "You no longer have access to the page you were viewing."
|
|
|
|
+ }
|
|
|
|
+ });
|
|
});
|
|
});
|
|
});
|
|
});
|
|
|
|
|
|
if (await lofig.get("siteSettings.mediasession")) ms.init();
|
|
if (await lofig.get("siteSettings.mediasession")) ms.init();
|
|
|
|
|
|
app.mount("#root");
|
|
app.mount("#root");
|
|
-})();
|
|
|
|
|
|
+});
|