|
@@ -24,14 +24,14 @@
|
|
<div class="nav-right nav-menu" :class="{ 'is-active': isMobile }">
|
|
<div class="nav-right nav-menu" :class="{ 'is-active': isMobile }">
|
|
<router-link
|
|
<router-link
|
|
v-if="role === 'admin'"
|
|
v-if="role === 'admin'"
|
|
- class="nav-item is-tab admin"
|
|
|
|
|
|
+ class="nav-item admin"
|
|
to="/admin"
|
|
to="/admin"
|
|
>
|
|
>
|
|
<strong>Admin</strong>
|
|
<strong>Admin</strong>
|
|
</router-link>
|
|
</router-link>
|
|
<span v-if="loggedIn" class="grouped">
|
|
<span v-if="loggedIn" class="grouped">
|
|
<router-link
|
|
<router-link
|
|
- class="nav-item is-tab"
|
|
|
|
|
|
+ class="nav-item "
|
|
:to="{
|
|
:to="{
|
|
name: 'profile',
|
|
name: 'profile',
|
|
params: { username }
|
|
params: { username }
|
|
@@ -39,10 +39,10 @@
|
|
>
|
|
>
|
|
Profile
|
|
Profile
|
|
</router-link>
|
|
</router-link>
|
|
- <router-link class="nav-item is-tab" to="/settings"
|
|
|
|
|
|
+ <router-link class="nav-item" to="/settings"
|
|
>Settings</router-link
|
|
>Settings</router-link
|
|
>
|
|
>
|
|
- <a class="nav-item is-tab" href="#" @click="logout()">Logout</a>
|
|
|
|
|
|
+ <a class="nav-item" href="#" @click="logout()">Logout</a>
|
|
</span>
|
|
</span>
|
|
<span v-if="!loggedIn && !hideLoggedOut" class="grouped">
|
|
<span v-if="!loggedIn && !hideLoggedOut" class="grouped">
|
|
<a class="nav-item" href="#" @click="openModal('login')"
|
|
<a class="nav-item" href="#" @click="openModal('login')"
|
|
@@ -52,12 +52,29 @@
|
|
>Register</a
|
|
>Register</a
|
|
>
|
|
>
|
|
</span>
|
|
</span>
|
|
|
|
+ <div class="nav-item" id="nightmode-toggle">
|
|
|
|
+ <p class="is-expanded checkbox-control">
|
|
|
|
+ <label class="switch">
|
|
|
|
+ <input
|
|
|
|
+ type="checkbox"
|
|
|
|
+ id="instant-nightmode"
|
|
|
|
+ v-model="localNightmode"
|
|
|
|
+ />
|
|
|
|
+ <span class="slider round"></span>
|
|
|
|
+ </label>
|
|
|
|
+
|
|
|
|
+ <label for="instant-nightmode">
|
|
|
|
+ <p>Nightmode</p>
|
|
|
|
+ </label>
|
|
|
|
+ </p>
|
|
|
|
+ </div>
|
|
</div>
|
|
</div>
|
|
</nav>
|
|
</nav>
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script>
|
|
<script>
|
|
-import { mapState, mapActions } from "vuex";
|
|
|
|
|
|
+import Toast from "toasters";
|
|
|
|
+import { mapState, mapGetters, mapActions } from "vuex";
|
|
|
|
|
|
export default {
|
|
export default {
|
|
props: {
|
|
props: {
|
|
@@ -67,6 +84,7 @@ export default {
|
|
},
|
|
},
|
|
data() {
|
|
data() {
|
|
return {
|
|
return {
|
|
|
|
+ localNightmode: null,
|
|
isMobile: false,
|
|
isMobile: false,
|
|
frontendDomain: "",
|
|
frontendDomain: "",
|
|
siteSettings: {
|
|
siteSettings: {
|
|
@@ -75,20 +93,68 @@ export default {
|
|
}
|
|
}
|
|
};
|
|
};
|
|
},
|
|
},
|
|
- computed: mapState({
|
|
|
|
- modals: state => state.modalVisibility.modals.header,
|
|
|
|
- role: state => state.user.auth.role,
|
|
|
|
- loggedIn: state => state.user.auth.loggedIn,
|
|
|
|
- username: state => state.user.auth.username
|
|
|
|
- }),
|
|
|
|
|
|
+ computed: {
|
|
|
|
+ ...mapState({
|
|
|
|
+ modals: state => state.modalVisibility.modals.header,
|
|
|
|
+ role: state => state.user.auth.role,
|
|
|
|
+ loggedIn: state => state.user.auth.loggedIn,
|
|
|
|
+ username: state => state.user.auth.username,
|
|
|
|
+ autoSkipDisliked: state => state.user.preferences.autoSkipDisliked,
|
|
|
|
+ activityLogPublic: state =>
|
|
|
|
+ state.user.preferences.activityLogPublic,
|
|
|
|
+ anonymousSongRequests: state =>
|
|
|
|
+ state.user.preferences.anonymousSongRequests,
|
|
|
|
+ activityWatch: state => state.user.preferences.activityWatch
|
|
|
|
+ }),
|
|
|
|
+ ...mapGetters({
|
|
|
|
+ socket: "websockets/getSocket"
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ watch: {
|
|
|
|
+ localNightmode(newValue, oldValue) {
|
|
|
|
+ if (oldValue === null) return;
|
|
|
|
+
|
|
|
|
+ localStorage.setItem("nightmode", this.localNightmode);
|
|
|
|
+
|
|
|
|
+ if (this.loggedIn) {
|
|
|
|
+ this.socket.dispatch(
|
|
|
|
+ "users.updatePreferences",
|
|
|
|
+ {
|
|
|
|
+ nightmode: this.localNightmode,
|
|
|
|
+ autoSkipDisliked: this.autoSkipDisliked,
|
|
|
|
+ activityLogPublic: this.activityLogPublic,
|
|
|
|
+ anonymousSongRequests: this.anonymousSongRequests,
|
|
|
|
+ activityWatch: this.activityWatch
|
|
|
|
+ },
|
|
|
|
+ res => {
|
|
|
|
+ if (res.status !== "success") new Toast(res.message);
|
|
|
|
+ }
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ this.changeNightmode(this.localNightmode);
|
|
|
|
+ }
|
|
|
|
+ },
|
|
async mounted() {
|
|
async mounted() {
|
|
|
|
+ this.localNightmode = JSON.parse(localStorage.getItem("nightmode"));
|
|
|
|
+
|
|
|
|
+ this.socket.dispatch("users.getPreferences", res => {
|
|
|
|
+ if (res.status === "success")
|
|
|
|
+ this.localNightmode = res.data.preferences.nightmode;
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ this.socket.on("keep.event:user.preferences.updated", res => {
|
|
|
|
+ this.localNightmode = res.data.preferences.nightmode;
|
|
|
|
+ });
|
|
|
|
+
|
|
this.frontendDomain = await lofig.get("frontendDomain");
|
|
this.frontendDomain = await lofig.get("frontendDomain");
|
|
this.siteSettings = await lofig.get("siteSettings");
|
|
this.siteSettings = await lofig.get("siteSettings");
|
|
},
|
|
},
|
|
|
|
|
|
methods: {
|
|
methods: {
|
|
...mapActions("modalVisibility", ["openModal"]),
|
|
...mapActions("modalVisibility", ["openModal"]),
|
|
- ...mapActions("user/auth", ["logout"])
|
|
|
|
|
|
+ ...mapActions("user/auth", ["logout"]),
|
|
|
|
+ ...mapActions("user/preferences", ["changeNightmode"])
|
|
}
|
|
}
|
|
};
|
|
};
|
|
</script>
|
|
</script>
|