mark single notifs as seen properly on server
This commit is contained in:
parent
36dcfa8cc1
commit
20b53d58b7
|
@ -18,11 +18,11 @@ const FollowRequestCard = {
|
||||||
this.$store.dispatch('removeFollowRequest', this.user)
|
this.$store.dispatch('removeFollowRequest', this.user)
|
||||||
|
|
||||||
const notifId = this.findFollowRequestNotificationId()
|
const notifId = this.findFollowRequestNotificationId()
|
||||||
|
this.$store.dispatch('markSingleNotificationAsSeen', { id: notifId })
|
||||||
this.$store.dispatch('updateNotification', {
|
this.$store.dispatch('updateNotification', {
|
||||||
id: notifId,
|
id: notifId,
|
||||||
updater: notification => {
|
updater: notification => {
|
||||||
notification.type = 'follow'
|
notification.type = 'follow'
|
||||||
notification.seen = true
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
|
@ -37,11 +37,11 @@ const Notification = {
|
||||||
approveUser () {
|
approveUser () {
|
||||||
this.$store.state.api.backendInteractor.approveUser({ id: this.user.id })
|
this.$store.state.api.backendInteractor.approveUser({ id: this.user.id })
|
||||||
this.$store.dispatch('removeFollowRequest', this.user)
|
this.$store.dispatch('removeFollowRequest', this.user)
|
||||||
|
this.$store.dispatch('markSingleNotificationAsSeen', { id: this.notification.id })
|
||||||
this.$store.dispatch('updateNotification', {
|
this.$store.dispatch('updateNotification', {
|
||||||
id: this.notification.id,
|
id: this.notification.id,
|
||||||
updater: notification => {
|
updater: notification => {
|
||||||
notification.type = 'follow'
|
notification.type = 'follow'
|
||||||
notification.seen = true
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
|
@ -525,6 +525,10 @@ export const mutations = {
|
||||||
notification.seen = true
|
notification.seen = true
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
markSingleNotificationAsSeen (state, { id }) {
|
||||||
|
const notification = find(state.notifications.data, n => n.id === id)
|
||||||
|
if (notification) notification.seen = true
|
||||||
|
},
|
||||||
dismissNotification (state, { id }) {
|
dismissNotification (state, { id }) {
|
||||||
state.notifications.data = state.notifications.data.filter(n => n.id !== id)
|
state.notifications.data = state.notifications.data.filter(n => n.id !== id)
|
||||||
},
|
},
|
||||||
|
@ -691,6 +695,14 @@ const statuses = {
|
||||||
credentials: rootState.users.currentUser.credentials
|
credentials: rootState.users.currentUser.credentials
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
markSingleNotificationAsSeen ({ rootState, commit }, { id }) {
|
||||||
|
commit('markSingleNotificationAsSeen', { id })
|
||||||
|
apiService.markNotificationsAsSeen({
|
||||||
|
single: true,
|
||||||
|
id,
|
||||||
|
credentials: rootState.users.currentUser.credentials
|
||||||
|
})
|
||||||
|
},
|
||||||
dismissNotification ({ rootState, commit }, { id }) {
|
dismissNotification ({ rootState, commit }, { id }) {
|
||||||
rootState.api.backendInteractor.dismissNotification({ id })
|
rootState.api.backendInteractor.dismissNotification({ id })
|
||||||
.then(() => commit('dismissNotification', { id }))
|
.then(() => commit('dismissNotification', { id }))
|
||||||
|
|
|
@ -4,7 +4,6 @@ import 'whatwg-fetch'
|
||||||
import { RegistrationError, StatusCodeError } from '../errors/errors'
|
import { RegistrationError, StatusCodeError } from '../errors/errors'
|
||||||
|
|
||||||
/* eslint-env browser */
|
/* eslint-env browser */
|
||||||
const QVITTER_USER_NOTIFICATIONS_READ_URL = '/api/qvitter/statuses/notifications/read.json'
|
|
||||||
const BLOCKS_IMPORT_URL = '/api/pleroma/blocks_import'
|
const BLOCKS_IMPORT_URL = '/api/pleroma/blocks_import'
|
||||||
const FOLLOW_IMPORT_URL = '/api/pleroma/follow_import'
|
const FOLLOW_IMPORT_URL = '/api/pleroma/follow_import'
|
||||||
const DELETE_ACCOUNT_URL = '/api/pleroma/delete_account'
|
const DELETE_ACCOUNT_URL = '/api/pleroma/delete_account'
|
||||||
|
@ -17,6 +16,7 @@ const DEACTIVATE_USER_URL = '/api/pleroma/admin/users/deactivate'
|
||||||
const ADMIN_USERS_URL = '/api/pleroma/admin/users'
|
const ADMIN_USERS_URL = '/api/pleroma/admin/users'
|
||||||
const SUGGESTIONS_URL = '/api/v1/suggestions'
|
const SUGGESTIONS_URL = '/api/v1/suggestions'
|
||||||
const NOTIFICATION_SETTINGS_URL = '/api/pleroma/notification_settings'
|
const NOTIFICATION_SETTINGS_URL = '/api/pleroma/notification_settings'
|
||||||
|
const NOTIFICATION_READ_URL = '/api/v1/pleroma/notifications/read'
|
||||||
|
|
||||||
const MFA_SETTINGS_URL = '/api/pleroma/accounts/mfa'
|
const MFA_SETTINGS_URL = '/api/pleroma/accounts/mfa'
|
||||||
const MFA_BACKUP_CODES_URL = '/api/pleroma/accounts/mfa/backup_codes'
|
const MFA_BACKUP_CODES_URL = '/api/pleroma/accounts/mfa/backup_codes'
|
||||||
|
@ -845,12 +845,16 @@ const suggestions = ({ credentials }) => {
|
||||||
}).then((data) => data.json())
|
}).then((data) => data.json())
|
||||||
}
|
}
|
||||||
|
|
||||||
const markNotificationsAsSeen = ({ id, credentials }) => {
|
const markNotificationsAsSeen = ({ id, credentials, single = false }) => {
|
||||||
const body = new FormData()
|
const body = new FormData()
|
||||||
|
|
||||||
body.append('latest_id', id)
|
if (single) {
|
||||||
|
body.append('id', id)
|
||||||
|
} else {
|
||||||
|
body.append('max_id', id)
|
||||||
|
}
|
||||||
|
|
||||||
return fetch(QVITTER_USER_NOTIFICATIONS_READ_URL, {
|
return fetch(NOTIFICATION_READ_URL, {
|
||||||
body,
|
body,
|
||||||
headers: authHeaders(credentials),
|
headers: authHeaders(credentials),
|
||||||
method: 'POST'
|
method: 'POST'
|
||||||
|
|
Loading…
Reference in New Issue