continue refactor

This commit is contained in:
Henry Jameson 2023-11-16 20:09:16 +02:00
parent aad3225d25
commit 6ed2cb8f43
2 changed files with 5 additions and 12 deletions

View File

@ -57,9 +57,7 @@ export const notifications = {
}, },
dismissNotification (state, { id }) { dismissNotification (state, { id }) {
state.data = state.data.filter(n => n.id !== id) state.data = state.data.filter(n => n.id !== id)
}, delete state.idStore[id]
dismissNotifications (state, { finder }) {
state.data = state.data.filter(n => finder)
}, },
updateNotification (state, { id, updater }) { updateNotification (state, { id, updater }) {
const notification = find(state.data, n => n.id === id) const notification = find(state.data, n => n.id === id)
@ -88,7 +86,6 @@ export const notifications = {
statusNotifications.forEach(notification => { statusNotifications.forEach(notification => {
const id = notification.status.id const id = notification.status.id
const referenceStatus = rootState.statuses.allStatusesObject[id] const referenceStatus = rootState.statuses.allStatusesObject[id]
console.log()
if (referenceStatus) { if (referenceStatus) {
notification.status = referenceStatus notification.status = referenceStatus
@ -108,14 +105,13 @@ export const notifications = {
// eslint-disable-next-line no-prototype-builtins // eslint-disable-next-line no-prototype-builtins
if (!state.idStore.hasOwnProperty(notification.id)) { if (!state.idStore.hasOwnProperty(notification.id)) {
commit('updateNotificationsMinMaxId', notification.id) commit('updateNotificationsMinMaxId', notification.id)
commit('addNewNotifications', { notifications: [notification] })
maybeShowNotification(store, notification) maybeShowNotification(store, notification)
} else if (notification.seen) { } else if (notification.seen) {
state.idStore[notification.id].seen = true state.idStore[notification.id].seen = true
} }
}) })
commit('addNewNotifications', { notifications })
}, },
setNotificationsLoading ({ rootState, commit }, { value }) { setNotificationsLoading ({ rootState, commit }, { value }) {
commit('setNotificationsLoading', { value }) commit('setNotificationsLoading', { value })

View File

@ -139,11 +139,11 @@ const addStatusToGlobalStorage = (state, data) => {
return result return result
} }
// XXX: this isn't actually really used anymore since deletes just don't appear outside streaming, thanks masto
// Remove status from the global storages (arrays and objects maintaining statuses) except timelines // Remove status from the global storages (arrays and objects maintaining statuses) except timelines
const removeStatusFromGlobalStorage = (state, status) => { const removeStatusFromGlobalStorage = (state, status) => {
remove(state.allStatuses, { id: status.id }) remove(state.allStatuses, { id: status.id })
delete state.allStatusesObject[status.id]
// TODO: Need to remove from allStatusesObject?
// Remove from conversation // Remove from conversation
const conversationId = status.statusnet_conversation_id const conversationId = status.statusnet_conversation_id
@ -516,11 +516,8 @@ export const mutations = {
const statuses = { const statuses = {
state: defaultState(), state: defaultState(),
actions: { actions: {
addNewStatuses ({ rootState, commit }, { statuses, showImmediately = false, timeline = false, noIdUpdate = false, userId, pagination }) { addNewStatuses ({ rootState, commit, dispatch, state }, { statuses, showImmediately = false, timeline = false, noIdUpdate = false, userId, pagination }) {
commit('addNewStatuses', { statuses, showImmediately, timeline, noIdUpdate, user: rootState.users.currentUser, userId, pagination }) commit('addNewStatuses', { statuses, showImmediately, timeline, noIdUpdate, user: rootState.users.currentUser, userId, pagination })
const deletions = statuses.filter(status => status.type === 'deletion')
console.log(deletions)
}, },
fetchStatus ({ rootState, dispatch }, id) { fetchStatus ({ rootState, dispatch }, id) {
return rootState.api.backendInteractor.fetchStatus({ id }) return rootState.api.backendInteractor.fetchStatus({ id })