store sensitive/spoiler on/off choices

This commit is contained in:
Nolan Lawson 2018-01-23 20:56:07 -08:00
parent 9453b327b7
commit 2a215480e2

View file

@ -291,6 +291,7 @@
import { mark, stop } from '../_utils/marks' import { mark, stop } from '../_utils/marks'
import IntlRelativeFormat from 'intl-relativeformat' import IntlRelativeFormat from 'intl-relativeformat'
import { replaceAll } from '../_utils/replaceAll' import { replaceAll } from '../_utils/replaceAll'
import { store } from '../_utils/store'
const relativeFormat = new IntlRelativeFormat('en-US'); const relativeFormat = new IntlRelativeFormat('en-US');
@ -303,6 +304,7 @@
Media, Media,
Toolbar Toolbar
}, },
store: () => store,
computed: { computed: {
createdAtDate: (status) => status.created_at, createdAtDate: (status) => status.created_at,
relativeDate: (createdAtDate) => { relativeDate: (createdAtDate) => {
@ -314,6 +316,7 @@
originalStatus: (status) => status.reblog ? status.reblog : status, originalStatus: (status) => status.reblog ? status.reblog : status,
originalAccount: (originalStatus) => originalStatus.account, originalAccount: (originalStatus) => originalStatus.account,
originalMediaAttachments: (originalStatus) => originalStatus.media_attachments, originalMediaAttachments: (originalStatus) => originalStatus.media_attachments,
statusId: (originalStatus) => originalStatus.id,
emojifiedContent: (originalStatus) => { emojifiedContent: (originalStatus) => {
let status = originalStatus let status = originalStatus
let content = status.content let content = status.content
@ -329,16 +332,24 @@
} }
} }
return content return content
} },
spoilerShown: ($spoilersShown, statusId) => $spoilersShown && $spoilersShown[statusId],
sensitiveShown: ($sensitivesShown, statusId) => $sensitivesShown && $sensitivesShown[statusId],
}, },
methods: { methods: {
onClickSpoilerButton() { onClickSpoilerButton() {
this.set({spoilerShown: !this.get('spoilerShown')}) let $spoilersShown = this.store.get('spoilersShown') || {}
let statusId = this.get('statusId')
$spoilersShown[statusId] = !$spoilersShown[statusId]
this.store.set({'spoilersShown': $spoilersShown})
this.hashtagifyContent() this.hashtagifyContent()
this.fire('recalculateHeight') this.fire('recalculateHeight')
}, },
onClickSensitiveMediaButton() { onClickSensitiveMediaButton() {
this.set({sensitiveShown: !this.get('sensitiveShown')}) let $sensitivesShown = this.store.get('sensitivesShown') || {}
let statusId = this.get('statusId')
$sensitivesShown[statusId] = !$sensitivesShown[statusId]
this.store.set({'sensitivesShown': $sensitivesShown})
this.fire('recalculateHeight') this.fire('recalculateHeight')
}, },
hashtagifyContent() { hashtagifyContent() {