Merge branch 'notifications-thru-sw' into shigusegubu-vue3
This commit is contained in:
commit
ff6f93f2e6
3 changed files with 1 additions and 104 deletions
|
@ -113,7 +113,7 @@ export const notifications = {
|
|||
}
|
||||
})
|
||||
},
|
||||
notificationClicked ({ state, commit }, id) {
|
||||
notificationClicked ({ state, commit }, { id }) {
|
||||
const notification = state.idStore[id]
|
||||
const { type, seen } = notification
|
||||
|
||||
|
|
|
@ -139,19 +139,6 @@ const addStatusToGlobalStorage = (state, data) => {
|
|||
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
|
||||
const removeStatusFromGlobalStorage = (state, status) => {
|
||||
remove(state.allStatuses, { id: status.id })
|
||||
delete state.allStatusesObject[status.id]
|
||||
|
||||
// Remove from conversation
|
||||
const conversationId = status.statusnet_conversation_id
|
||||
if (state.conversationsObject[conversationId]) {
|
||||
remove(state.conversationsObject[conversationId], { id: status.id })
|
||||
}
|
||||
}
|
||||
|
||||
const addNewStatuses = (state, { statuses, showImmediately = false, timeline, user = {}, noIdUpdate = false, userId, pagination = {} }) => {
|
||||
// Sanity check
|
||||
if (!isArray(statuses)) {
|
||||
|
@ -285,20 +272,6 @@ const addNewStatuses = (state, { statuses, showImmediately = false, timeline, us
|
|||
favoriteStatus(favorite)
|
||||
}
|
||||
},
|
||||
deletion: (deletion) => {
|
||||
const uri = deletion.uri
|
||||
const status = find(allStatuses, { uri })
|
||||
if (!status) {
|
||||
return
|
||||
}
|
||||
|
||||
removeStatusFromGlobalStorage(state, status)
|
||||
|
||||
if (timeline) {
|
||||
remove(timelineObject.statuses, { uri })
|
||||
remove(timelineObject.visibleStatuses, { uri })
|
||||
}
|
||||
},
|
||||
follow: (follow) => {
|
||||
// NOOP, it is known status but we don't do anything about it for now
|
||||
},
|
||||
|
|
|
@ -77,24 +77,6 @@ describe('Statuses module', () => {
|
|||
expect(state.timelines.public.newStatusCount).to.equal(0)
|
||||
})
|
||||
|
||||
it('removes statuses by tag on deletion', () => {
|
||||
const state = defaultState()
|
||||
const status = makeMockStatus({ id: '1' })
|
||||
const otherStatus = makeMockStatus({ id: '3' })
|
||||
status.uri = 'xxx'
|
||||
const deletion = makeMockStatus({ id: '2', type: 'deletion' })
|
||||
deletion.text = 'Dolus deleted notice {{tag:gs.smuglo.li,2016-11-18:noticeId=1038007:objectType=note}}.'
|
||||
deletion.uri = 'xxx'
|
||||
|
||||
mutations.addNewStatuses(state, { statuses: [status, otherStatus], showImmediately: true, timeline: 'public' })
|
||||
mutations.addNewStatuses(state, { statuses: [deletion], showImmediately: true, timeline: 'public' })
|
||||
|
||||
expect(state.allStatuses).to.eql([otherStatus])
|
||||
expect(state.timelines.public.statuses).to.eql([otherStatus])
|
||||
expect(state.timelines.public.visibleStatuses).to.eql([otherStatus])
|
||||
expect(state.timelines.public.maxId).to.eql('3')
|
||||
})
|
||||
|
||||
it('does not update the maxId when the noIdUpdate flag is set', () => {
|
||||
const state = defaultState()
|
||||
const status = makeMockStatus({ id: '1' })
|
||||
|
@ -315,62 +297,4 @@ describe('Statuses module', () => {
|
|||
expect(state.timelines.user.userId).to.eql(123)
|
||||
})
|
||||
})
|
||||
|
||||
describe('notifications', () => {
|
||||
it('removes a notification when the notice gets removed', () => {
|
||||
const user = { id: '1' }
|
||||
const state = defaultState()
|
||||
const status = makeMockStatus({ id: '1' })
|
||||
const otherStatus = makeMockStatus({ id: '3' })
|
||||
const mentionedStatus = makeMockStatus({ id: '2' })
|
||||
mentionedStatus.attentions = [user]
|
||||
mentionedStatus.uri = 'xxx'
|
||||
otherStatus.attentions = [user]
|
||||
|
||||
const deletion = makeMockStatus({ id: '4', type: 'deletion' })
|
||||
deletion.text = 'Dolus deleted notice {{tag:gs.smuglo.li,2016-11-18:noticeId=1038007:objectType=note}}.'
|
||||
deletion.uri = 'xxx'
|
||||
const newNotificationSideEffects = () => {}
|
||||
mutations.addNewStatuses(state, { statuses: [status, otherStatus], user })
|
||||
mutations.addNewNotifications(
|
||||
state,
|
||||
{
|
||||
notifications: [{
|
||||
from_profile: { id: '2' },
|
||||
id: '998',
|
||||
type: 'mention',
|
||||
status: otherStatus,
|
||||
action: otherStatus,
|
||||
seen: false
|
||||
}],
|
||||
newNotificationSideEffects
|
||||
})
|
||||
|
||||
expect(state.notifications.data.length).to.eql(1)
|
||||
mutations.addNewNotifications(
|
||||
state,
|
||||
{
|
||||
notifications: [{
|
||||
from_profile: { id: '2' },
|
||||
id: '999',
|
||||
type: 'mention',
|
||||
status: mentionedStatus,
|
||||
action: mentionedStatus,
|
||||
seen: false
|
||||
}],
|
||||
newNotificationSideEffects
|
||||
})
|
||||
|
||||
mutations.addNewStatuses(state, { statuses: [mentionedStatus], user })
|
||||
expect(state.allStatuses.length).to.eql(3)
|
||||
expect(state.notifications.data.length).to.eql(2)
|
||||
expect(state.notifications.data[1].status).to.eql(mentionedStatus)
|
||||
expect(state.notifications.data[1].action).to.eql(mentionedStatus)
|
||||
expect(state.notifications.data[1].type).to.eql('mention')
|
||||
|
||||
mutations.addNewStatuses(state, { statuses: [deletion], user })
|
||||
expect(state.allStatuses.length).to.eql(2)
|
||||
expect(state.notifications.data.length).to.eql(1)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Add table
Reference in a new issue