From 963a0035e5e3f35ee790aeb3db64cb8dd32a84a4 Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Sat, 18 Feb 2017 20:42:00 +0100 Subject: Make page title dynamic, better notification handling. --- src/modules/config.js | 7 +++++-- src/modules/statuses.js | 7 ++++++- 2 files changed, 11 insertions(+), 3 deletions(-) (limited to 'src/modules') diff --git a/src/modules/config.js b/src/modules/config.js index 4365d554..8d850f2a 100644 --- a/src/modules/config.js +++ b/src/modules/config.js @@ -13,11 +13,14 @@ const config = { } }, actions: { - setOption ({ commit }, { name, value }) { + setPageTitle ({state}, option = '') { + document.title = `${state.name} ${option}` + }, + setOption ({ commit, dispatch }, { name, value }) { commit('setOption', {name, value}) switch (name) { case 'name': - document.title = value + dispatch('setPageTitle') break case 'theme': const fullPath = `/static/css/${value}` diff --git a/src/modules/statuses.js b/src/modules/statuses.js index 871172b5..0967f77a 100644 --- a/src/modules/statuses.js +++ b/src/modules/statuses.js @@ -173,7 +173,7 @@ const addNewStatuses = (state, { statuses, showImmediately = false, timeline, us } const addNotification = ({type, status, action}) => { - state.notifications.push({type, status, action}) + state.notifications.push({type, status, action, seen: false}) } const favoriteStatus = (favorite) => { @@ -276,6 +276,11 @@ export const mutations = { setNsfw (state, { id, nsfw }) { const newStatus = find(state.allStatuses, { id }) newStatus.nsfw = nsfw + }, + markNotificationsAsSeen (state, notifications) { + each(notifications, (notification) => { + notification.seen = true + }) } } -- cgit v1.2.3-70-g09d2 From 209e8614b09ab7f24262d86de0924bd2e0dd96ec Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Sat, 18 Feb 2017 20:56:03 +0100 Subject: Don't add notifications twice + persiste them. --- src/main.js | 2 +- src/modules/statuses.js | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'src/modules') diff --git a/src/main.js b/src/main.js index 4b367db9..841e61a7 100644 --- a/src/main.js +++ b/src/main.js @@ -29,7 +29,7 @@ Vue.use(VueTimeago, { }) const persistedStateOptions = { - paths: ['users.users'] + paths: ['users.users', 'statuses.notifications'] } const store = new Vuex.Store({ diff --git a/src/modules/statuses.js b/src/modules/statuses.js index 0967f77a..491d0024 100644 --- a/src/modules/statuses.js +++ b/src/modules/statuses.js @@ -173,7 +173,10 @@ const addNewStatuses = (state, { statuses, showImmediately = false, timeline, us } const addNotification = ({type, status, action}) => { - state.notifications.push({type, status, action, seen: false}) + // Only add a new notification if we don't have one for the same action + if (!find(state.notifications, (oldNotification) => oldNotification.action.id === action.id)) { + state.notifications.push({type, status, action, seen: false}) + } } const favoriteStatus = (favorite) => { -- cgit v1.2.3-70-g09d2