From 209e8614b09ab7f24262d86de0924bd2e0dd96ec Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Sat, 18 Feb 2017 20:56:03 +0100 Subject: [PATCH] Don't add notifications twice + persiste them. --- src/main.js | 2 +- src/modules/statuses.js | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main.js b/src/main.js index 4b367db995..841e61a74a 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 0967f77a34..491d0024f9 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) => {