Don't add notifications twice + persiste them.

This commit is contained in:
Roger Braun 2017-02-18 20:56:03 +01:00
parent 963a0035e5
commit 209e8614b0
2 changed files with 5 additions and 2 deletions

View file

@ -29,7 +29,7 @@ Vue.use(VueTimeago, {
}) })
const persistedStateOptions = { const persistedStateOptions = {
paths: ['users.users'] paths: ['users.users', 'statuses.notifications']
} }
const store = new Vuex.Store({ const store = new Vuex.Store({

View file

@ -173,7 +173,10 @@ const addNewStatuses = (state, { statuses, showImmediately = false, timeline, us
} }
const addNotification = ({type, status, action}) => { 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) => { const favoriteStatus = (favorite) => {