diff options
| author | Shpuld Shpuldson <shpuld@gmail.com> | 2017-06-19 11:32:40 +0300 |
|---|---|---|
| committer | Shpuld Shpuldson <shpuld@gmail.com> | 2017-06-19 11:32:40 +0300 |
| commit | 3785a863cb27af18fe91403189eff16f662dc2d0 (patch) | |
| tree | ff1ee977f74e9516fec4ca0691b017ce6f7867ff /src/modules/statuses.js | |
| parent | 143aa3b990c0e0fac98c4a097d68e9f7518f1940 (diff) | |
| parent | 8e5d17a659b157f095ad3850ac3cdd2e537ac38b (diff) | |
Update branch and fix conflicts.
Diffstat (limited to 'src/modules/statuses.js')
| -rw-r--r-- | src/modules/statuses.js | 44 |
1 files changed, 41 insertions, 3 deletions
diff --git a/src/modules/statuses.js b/src/modules/statuses.js index 051ec71b..084800fa 100644 --- a/src/modules/statuses.js +++ b/src/modules/statuses.js @@ -1,4 +1,4 @@ -import { remove, slice, sortBy, toInteger, each, find, flatten, maxBy, last, merge, max, isArray } from 'lodash' +import { includes, remove, slice, sortBy, toInteger, each, find, flatten, maxBy, last, merge, max, isArray } from 'lodash' import apiService from '../services/api/api.service.js' // import parse from '../services/status_parser/status_parser.js' @@ -32,6 +32,17 @@ export const defaultState = { minVisibleId: 0, loading: false }, + user: { + statuses: [], + statusesObject: {}, + faves: [], + visibleStatuses: [], + visibleStatusesObject: {}, + newStatusCount: 0, + maxId: 0, + minVisibleId: 0, + loading: false + }, publicAndExternal: { statuses: [], statusesObject: {}, @@ -57,11 +68,15 @@ export const defaultState = { } } +const isNsfw = (status) => { + const nsfwRegex = /#nsfw/i + return includes(status.tags, 'nsfw') || !!status.text.match(nsfwRegex) +} + export const prepareStatus = (status) => { // Parse nsfw tags if (status.nsfw === undefined) { - const nsfwRegex = /#nsfw/i - status.nsfw = !!status.text.match(nsfwRegex) + status.nsfw = isNsfw(status) } // Set deleted flag @@ -242,6 +257,14 @@ const addNewStatuses = (state, { statuses, showImmediately = false, timeline, us const uri = deletion.uri updateMaxId(deletion) + // Remove possible notification + const status = find(allStatuses, {uri}) + if (!status) { + return + } + + remove(state.notifications, ({action: {id}}) => id === status.id) + remove(allStatuses, { uri }) if (timeline) { remove(timelineObject.statuses, { uri }) @@ -276,6 +299,21 @@ export const mutations = { oldTimeline.visibleStatusesObject = {} each(oldTimeline.visibleStatuses, (status) => { oldTimeline.visibleStatusesObject[status.id] = status }) }, + clearTimeline (state, { timeline }) { + const emptyTimeline = { + statuses: [], + statusesObject: {}, + faves: [], + visibleStatuses: [], + visibleStatusesObject: {}, + newStatusCount: 0, + maxId: 0, + minVisibleId: 0, + loading: false + } + + state.timelines[timeline] = emptyTimeline + }, setFavorited (state, { status, value }) { const newStatus = state.allStatusesObject[status.id] newStatus.favorited = value |
