Move isNotified to vuex.

This commit is contained in:
Richard Lewis 2019-02-27 16:15:34 +02:00 committed by Pavel Djundik
parent 69cb891b1a
commit 0da059118d
5 changed files with 18 additions and 16 deletions

View File

@ -1,6 +1,7 @@
<template> <template>
<div <div
id="viewport" id="viewport"
:class="{notified: $store.state.isNotified}"
role="tablist"> role="tablist">
<Sidebar <Sidebar
:networks="networks" :networks="networks"

View File

@ -187,7 +187,7 @@ export default {
this.$refs.input.click(); this.$refs.input.click();
this.$refs.input.focus(); this.$refs.input.focus();
if (!$store.state.isConnected) { if (!this.$store.state.isConnected) {
return false; return false;
} }

View File

@ -5,11 +5,15 @@ Vue.use(Vuex);
export default new Vuex.Store({ export default new Vuex.Store({
state: { state: {
isConnected: false isConnected: false,
isNotified: false,
}, },
mutations: { mutations: {
isConnected(state, payload) { isConnected(state, payload) {
state.isConnected = payload; state.isConnected = payload;
}, },
isNotified(state, payload) {
state.isNotified = payload;
},
} }
}); });

View File

@ -67,17 +67,15 @@ function synchronizeNotifiedState() {
} }
function toggleNotificationMarkers(newState) { function toggleNotificationMarkers(newState) {
// Toggles the favicon to red when there are unread notifications if (vueApp.$store.state.isNotified !== newState) {
if (vueApp.isNotified !== newState) { // Toggles a dot on the menu icon when there are unread notifications
vueApp.isNotified = newState; vueApp.$store.commit("isNotified", newState);
// Toggles the favicon to red when there are unread notifications
const old = favicon.prop("href"); const old = favicon.prop("href");
favicon.prop("href", favicon.data("other")); favicon.prop("href", favicon.data("other"));
favicon.data("other", old); favicon.data("other", old);
} }
// Toggles a dot on the menu icon when there are unread notifications
viewport.toggleClass("notified", newState);
} }
function updateTitle() { function updateTitle() {

View File

@ -23,7 +23,6 @@ const vueApp = new Vue({
initialized: false, initialized: false,
isAutoCompleting: false, isAutoCompleting: false,
isFileUploadEnabled: false, isFileUploadEnabled: false,
isNotified: false,
networks: [], networks: [],
pushNotificationState: "unsupported", pushNotificationState: "unsupported",
desktopNotificationState: "unsupported", desktopNotificationState: "unsupported",