From 51988e75b6462bffc655fd5638325e0465201cbc Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Sun, 27 Nov 2016 18:54:51 +0100 Subject: [PATCH] Add repeat notifications. --- src/modules/statuses.js | 5 +++++ test/unit/specs/modules/statuses.spec.js | 16 ++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/src/modules/statuses.js b/src/modules/statuses.js index cee249e2b1..43d5d1acf6 100644 --- a/src/modules/statuses.js +++ b/src/modules/statuses.js @@ -121,6 +121,10 @@ const addNewStatuses = (state, { statuses, showImmediately = false, timeline, us if (result.new) { updateMaxId(status) + + if (statusType(status) === 'retweet' && status.retweeted_status.user.id === user.id) { + addNotification({ type: 'repeat', status: status.retweeted_status, action: status }) + } } // Some statuses should only be added to the global status repository. @@ -201,6 +205,7 @@ const addNewStatuses = (state, { statuses, showImmediately = false, timeline, us } }, 'default': (unknown) => { + console.log('unknown status type') console.log(unknown) } } diff --git a/test/unit/specs/modules/statuses.spec.js b/test/unit/specs/modules/statuses.spec.js index e6abbd91e2..bdb6293e5d 100644 --- a/test/unit/specs/modules/statuses.spec.js +++ b/test/unit/specs/modules/statuses.spec.js @@ -165,6 +165,22 @@ describe('The Statuses module', () => { expect(retweet.retweeted_status.text).to.eql(modStatus.text) }) + it('adds a notfications for retweets if you are the retweetet', () => { + const user = { id: 1 } + const state = cloneDeep(defaultState) + const status = makeMockStatus({id: 1}) + status.user = user + const retweet = makeMockStatus({id: 2, is_post_verb: false}) + retweet.retweeted_status = status + + mutations.addNewStatuses(state, { statuses: [retweet], user }) + + expect(state.notifications.length).to.eql(1) + expect(state.notifications[0].status).to.eql(status) + expect(state.notifications[0].action).to.eql(retweet) + expect(state.notifications[0].type).to.eql('repeat') + }) + it('replaces existing statuses with the same id', () => { const state = cloneDeep(defaultState) const status = makeMockStatus({id: 1})