From 4cef86f2a864ac643cf5efc43824d650beea8307 Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Fri, 18 Nov 2016 22:25:42 +0100 Subject: Add status deletion. Kind of wonky. Would be better if we used the AS endpoints. --- src/modules/statuses.js | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/modules/statuses.js b/src/modules/statuses.js index c088fa1a..510f9dbb 100644 --- a/src/modules/statuses.js +++ b/src/modules/statuses.js @@ -1,4 +1,4 @@ -import { map, slice, sortBy, toInteger, each, find, flatten, maxBy, last, merge, max } from 'lodash' +import { remove, map, slice, sortBy, toInteger, each, find, flatten, maxBy, last, merge, max } from 'lodash' import moment from 'moment' import apiService from '../services/api/api.service.js' // import parse from '../services/status_parser/status_parser.js' @@ -73,6 +73,10 @@ const statusType = (status) => { return 'favorite' } + if (status.text.match(/deleted notice {{tag/)) { + return 'deletion' + } + return 'unknown' } @@ -145,18 +149,37 @@ export const mutations = { 'retweet': (status) => { // RetweetedStatuses are never shown immediately const retweetedStatus = addStatus(status.retweeted_status, false, false) - const retweet = addStatus(status, showImmediately) + + let retweet + // If the retweeted status is already there, don't add the retweet + // to the timeline. + if (find(timelineObject.visibleStatuses, {id: retweetedStatus.id})) { + // Already have it visible, don't add to timeline, don't show. + retweet = addStatus(status, false, false) + } else { + retweet = addStatus(status, showImmediately) + } + retweet.retweeted_status = retweetedStatus }, - 'favorite': (status) => { - updateMaxId(status) - favoriteStatus(status) + 'favorite': (favorite) => { + updateMaxId(favorite) + favoriteStatus(favorite) + }, + 'deletion': ({uri}) => { + remove(allStatuses, { tag: uri }) + remove(timelineObject.statuses, { tag: uri }) + remove(timelineObject.visibleStatuses, { tag: uri }) + }, + 'default': (unknown) => { + console.log(unknown) } } each(statuses, (status) => { const type = statusType(status) - processors[type](status) + const processor = processors[type] || processors['default'] + processor(status) }) // Keep the visible statuses sorted -- cgit v1.2.3-70-g09d2