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>
<div
id="viewport"
:class="{notified: $store.state.isNotified}"
role="tablist">
<Sidebar
:networks="networks"

View file

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

View file

@ -4,12 +4,16 @@ import Vuex from "vuex";
Vue.use(Vuex);
export default new Vuex.Store({
state: {
isConnected: false
},
mutations: {
isConnected(state, payload) {
state.isConnected = payload;
},
}
state: {
isConnected: false,
isNotified: false,
},
mutations: {
isConnected(state, payload) {
state.isConnected = payload;
},
isNotified(state, payload) {
state.isNotified = payload;
},
}
});

View file

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

View file

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