From 05f9e68dab39fb0ce17caf71226a5737d28f33c8 Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Sat, 19 Nov 2016 13:08:44 +0100 Subject: [PATCH] Fixes for deletion. --- src/modules/statuses.js | 11 +++++++---- test/unit/specs/modules/statuses.spec.js | 5 +++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/modules/statuses.js b/src/modules/statuses.js index 7d5d3475..32118fec 100644 --- a/src/modules/statuses.js +++ b/src/modules/statuses.js @@ -173,10 +173,13 @@ export const mutations = { updateMaxId(favorite) favoriteStatus(favorite) }, - 'deletion': ({uri}) => { - remove(allStatuses, { tag: uri }) - remove(timelineObject.statuses, { tag: uri }) - remove(timelineObject.visibleStatuses, { tag: uri }) + 'deletion': (deletion) => { + const uri = deletion.uri + updateMaxId(deletion) + + remove(allStatuses, { uri }) + remove(timelineObject.statuses, { uri }) + remove(timelineObject.visibleStatuses, { uri }) }, 'default': (unknown) => { console.log(unknown) diff --git a/test/unit/specs/modules/statuses.spec.js b/test/unit/specs/modules/statuses.spec.js index 871de491..574e4f74 100644 --- a/test/unit/specs/modules/statuses.spec.js +++ b/test/unit/specs/modules/statuses.spec.js @@ -82,10 +82,10 @@ describe('The Statuses module', () => { it('removes statuses by tag on deletion', () => { const state = cloneDeep(defaultState) const status = makeMockStatus({id: 1}) - status.tag = 'xxx' + status.uri = 'xxx' const deletion = makeMockStatus({id: 2, is_post_verb: false}) deletion.text = 'Dolus deleted notice {{tag:gs.smuglo.li,2016-11-18:noticeId=1038007:objectType=note}}.' - deletion.uri = 'xxx' + deletion.uri= 'xxx' mutations.addNewStatuses(state, { statuses: [status], showImmediately: true, timeline: 'public' }) mutations.addNewStatuses(state, { statuses: [deletion], showImmediately: true, timeline: 'public' }) @@ -93,6 +93,7 @@ describe('The Statuses module', () => { expect(state.allStatuses).to.eql([]) expect(state.timelines.public.statuses).to.eql([]) expect(state.timelines.public.visibleStatuses).to.eql([]) + expect(state.timelines.public.maxId).to.eql(2) }) it('keeps a descending by id order in timeline.visibleStatuses and timeline.statuses', () => {