fix contextual toggling of spoilers/sensitives
This commit is contained in:
parent
542368fd3d
commit
f7b933815e
|
@ -8,13 +8,13 @@
|
|||
<StatusAuthor status="{{originalStatus}}" :isStatusInOwnThread />
|
||||
<StatusSidebar status="{{originalStatus}}" />
|
||||
{{#if originalStatus.spoiler_text}}
|
||||
<StatusSpoiler status="{{originalStatus}}" :spoilerShown on:recalculateHeight />
|
||||
<StatusSpoiler status="{{originalStatus}}" :contextualStatusId on:recalculateHeight />
|
||||
{{/if}}
|
||||
{{#if !originalStatus.spoiler_text || spoilerShown}}
|
||||
<StatusContent status="{{originalStatus}}" :isStatusInOwnThread />
|
||||
{{/if}}
|
||||
{{#if originalStatus.media_attachments && originalStatus.media_attachments.length}}
|
||||
<StatusMediaAttachments status="{{originalStatus}}" on:recalculateHeight />
|
||||
<StatusMediaAttachments status="{{originalStatus}}" :contextualStatusId on:recalculateHeight />
|
||||
{{/if}}
|
||||
<StatusToolbar :status />
|
||||
</article>
|
||||
|
@ -72,9 +72,10 @@
|
|||
computed: {
|
||||
originalStatus: (status) => status.reblog ? status.reblog : status,
|
||||
statusId: (originalStatus) => originalStatus.id,
|
||||
contextualStatusId: ($currentInstance, timelineType, timelineValue, status) => `${$currentInstance}/${timelineType}/${timelineValue}/${status.id}`,
|
||||
originalAccount: (originalStatus) => originalStatus.account,
|
||||
isStatusInOwnThread: (timelineType, timelineValue, statusId) => timelineType === 'status' && timelineValue === statusId,
|
||||
spoilerShown: ($spoilersShown, $currentInstance, statusId) => $spoilersShown && $spoilersShown[$currentInstance] && $spoilersShown[$currentInstance][statusId]
|
||||
spoilerShown: ($spoilersShown, contextualStatusId) => !!$spoilersShown[contextualStatusId]
|
||||
}
|
||||
}
|
||||
</script>
|
|
@ -120,20 +120,13 @@
|
|||
store: () => store,
|
||||
computed: {
|
||||
mediaAttachments: (status) => status.media_attachments,
|
||||
sensitiveShown: ($sensitivesShown, $currentInstance, statusId) => {
|
||||
return $sensitivesShown && $sensitivesShown[$currentInstance] && $sensitivesShown[$currentInstance][statusId]
|
||||
},
|
||||
statusId: (status) => status.id
|
||||
sensitiveShown: ($sensitivesShown, contextualStatusId) => !!$sensitivesShown[contextualStatusId]
|
||||
},
|
||||
methods: {
|
||||
onClickSensitiveMediaButton() {
|
||||
let statusId = this.get('statusId')
|
||||
let instanceName = this.store.get('currentInstance')
|
||||
let contextualStatusId = this.get('contextualStatusId')
|
||||
let $sensitivesShown = this.store.get('sensitivesShown') || {}
|
||||
if (!$sensitivesShown[instanceName]) {
|
||||
$sensitivesShown[instanceName] = {}
|
||||
}
|
||||
$sensitivesShown[instanceName][statusId] = !$sensitivesShown[instanceName][statusId]
|
||||
$sensitivesShown[contextualStatusId] = !$sensitivesShown[contextualStatusId]
|
||||
this.store.set({'sensitivesShown': $sensitivesShown})
|
||||
this.fire('recalculateHeight')
|
||||
},
|
||||
|
|
|
@ -30,17 +30,13 @@
|
|||
export default {
|
||||
store: () => store,
|
||||
computed: {
|
||||
statusId: (status) => status.id
|
||||
spoilerShown: ($spoilersShown, contextualStatusId) => !!$spoilersShown[contextualStatusId]
|
||||
},
|
||||
methods: {
|
||||
onClickSpoilerButton() {
|
||||
let statusId = this.get('statusId')
|
||||
let instanceName = this.store.get('currentInstance')
|
||||
let $spoilersShown = this.store.get('spoilersShown') || {}
|
||||
if (!$spoilersShown[instanceName]) {
|
||||
$spoilersShown[instanceName] = {}
|
||||
}
|
||||
$spoilersShown[instanceName][statusId] = !$spoilersShown[instanceName][statusId]
|
||||
let contextualStatusId = this.get('contextualStatusId')
|
||||
let $spoilersShown = this.store.get('spoilersShown')
|
||||
$spoilersShown[contextualStatusId] = !$spoilersShown[contextualStatusId]
|
||||
this.store.set({'spoilersShown': $spoilersShown})
|
||||
this.fire('recalculateHeight')
|
||||
}
|
||||
|
|
|
@ -26,7 +26,9 @@ const store = new PinaforeStore({
|
|||
loggedInInstances: {},
|
||||
loggedInInstancesInOrder: [],
|
||||
instanceThemes: {},
|
||||
autoplayGifs: false
|
||||
spoilersShown: {},
|
||||
sensitivesShown: {},
|
||||
autoplayGifs: false,
|
||||
})
|
||||
|
||||
mixins(PinaforeStore)
|
||||
|
|
Loading…
Reference in a new issue