diff --git a/src/components/attachment/attachment.js b/src/components/attachment/attachment.js index c21cd656..161c6b2b 100644 --- a/src/components/attachment/attachment.js +++ b/src/components/attachment/attachment.js @@ -3,17 +3,32 @@ import nsfwImage from '../../assets/nsfw.jpg' const Attachment = { props: [ 'attachment', - 'nsfw' + 'nsfw', + 'statusId' ], data: () => ({ nsfwImage }), computed: { type () { - return 'image' + let type = 'unknown' + + if(this.attachment.mimetype.match(/text\/html/)) { + type = 'html'; + } + + if(this.attachment.mimetype.match(/image/)) { + type = 'image'; + } + + if(this.attachment.mimetype.match(/video\/webm/)) { + type = 'webm'; + }; + + return type } }, methods: { showNsfw () { - this.nsfw = false + this.$store.commit('setNsfw', { id: this.statusId, nsfw: false }) } } } diff --git a/src/components/attachment/attachment.vue b/src/components/attachment/attachment.vue index 67c6ac18..d20b704b 100644 --- a/src/components/attachment/attachment.vue +++ b/src/components/attachment/attachment.vue @@ -5,21 +5,29 @@ - +
+
+ +
+
+

{{attachment.oembed.title}}

+
+
+
+ + diff --git a/src/components/status/status.js b/src/components/status/status.js index 2842ef0f..6ee8f0dd 100644 --- a/src/components/status/status.js +++ b/src/components/status/status.js @@ -2,9 +2,6 @@ import Attachment from '../attachment/attachment.vue' const Status = { props: [ 'statusoid' ], - data: () => ({ - nsfw: true - }), computed: { retweet () { return !!this.statusoid.retweeted_status }, retweeter () { return this.statusoid.user.name }, diff --git a/src/components/status/status.vue b/src/components/status/status.vue index 04a55f67..a6a5aac2 100644 --- a/src/components/status/status.vue +++ b/src/components/status/status.vue @@ -26,7 +26,7 @@
- +
@@ -49,3 +49,13 @@ + + diff --git a/src/components/timeline/timeline.vue b/src/components/timeline/timeline.vue index db18d521..8fdcc42f 100644 --- a/src/components/timeline/timeline.vue +++ b/src/components/timeline/timeline.vue @@ -11,3 +11,9 @@ + + diff --git a/src/modules/statuses.js b/src/modules/statuses.js index b0427694..d6bdba65 100644 --- a/src/modules/statuses.js +++ b/src/modules/statuses.js @@ -51,13 +51,18 @@ const addStatusesToTimeline = (addedStatuses, showImmediately, { statuses, visib addedStatuses = statusesAndFaves['status'] || [] - // Add some html to the statuses. + // Add some html and nsfw to the statuses. each(addedStatuses, (status) => { const statusoid = status.retweeted_status || status if (statusoid.parsedText === undefined) { // statusoid.parsedText = statusParserService.parse(statusoid) statusoid.parsedText = statusoid.text } + + if (statusoid.nsfw === undefined) { + const nsfwRegex = /#nsfw/i + statusoid.nsfw = statusoid.text.match(nsfwRegex) + } }) const newStatuses = sortBy( @@ -88,7 +93,9 @@ const addStatusesToTimeline = (addedStatuses, showImmediately, { statuses, visib } const updateTimestampsInStatuses = (statuses) => { - return map(statuses, (status) => { + return map(statuses, (statusoid) => { + const status = statusoid.retweeted_status || statusoid + // Parse date status.created_at_parsed = moment(status.created_at).fromNow() return status @@ -110,6 +117,16 @@ const statuses = { }, updateTimestamps (state) { updateTimestampsInStatuses(state.allStatuses) + }, + setNsfw (state, { id, nsfw }) { + // For now, walk through all the statuses because the stuff might be in the replied_to_status + // TODO: Save the replied_tos as references. + each(state.allStatuses, (statusoid) => { + const status = statusoid.retweeted_status || statusoid + if (status.id === id) { + status.nsfw = nsfw + } + }) } } }