aboutsummaryrefslogtreecommitdiff
path: root/src/modules/statuses.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules/statuses.js')
-rw-r--r--src/modules/statuses.js44
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