automatically insert CWs for replies to CWs

This commit is contained in:
Nolan Lawson 2018-04-03 09:45:17 -07:00
parent 9210afe0c3
commit 79e33d7938
4 changed files with 25 additions and 5 deletions

View file

@ -65,3 +65,15 @@ export async function clickSelectedAutosuggestionUsername (realm) {
let endIndex = selectionStart
await insertUsername(realm, account.acct, startIndex, endIndex)
}
export function setReplySpoiler (realm, spoiler) {
let contentWarning = store.getComposeData(realm, 'contentWarning')
let contentWarningShown = store.getComposeData(realm, 'contentWarningShown')
if (typeof contentWarningShown === 'undefined' && !contentWarning) {
// user hasn't interacted with the CW yet
store.setComposeData(realm, {
contentWarning: spoiler,
contentWarningShown: true
})
}
}

View file

@ -98,7 +98,7 @@
import { CHAR_LIMIT, POST_PRIVACY_OPTIONS } from '../../_static/statuses'
import { store } from '../../_store/store'
import { slide } from 'svelte-transitions'
import { postStatus, insertHandleForReply } from '../../_actions/compose'
import { postStatus, insertHandleForReply, setReplySpoiler } from '../../_actions/compose'
import { importDialogs } from '../../_utils/asyncModules'
import { classname } from '../../_utils/classname'
@ -119,6 +119,12 @@
insertHandleForReply(realm)
}
let replySpoiler = this.get('replySpoiler')
if (replySpoiler) {
// default spoiler is same as the replied-to status
setReplySpoiler(realm, replySpoiler)
}
this.observe('postedStatusForRealm', postedStatusForRealm => {
if (postedStatusForRealm !== realm) {
return

View file

@ -18,12 +18,12 @@
{{/if}}
<StatusSidebar :isStatusInOwnThread :originalAccount
:originalAccountId :uuid />
{{#if originalStatus.spoiler_text}}
{{#if spoilerText}}
<StatusSpoiler :isStatusInOwnThread :isStatusInNotification
:originalStatus :uuid :spoilerShown
on:recalculateHeight />
{{/if}}
{{#if !originalStatus.spoiler_text || spoilerShown}}
{{#if !spoilerText || spoilerShown}}
<StatusContent :isStatusInOwnThread :isStatusInNotification
:originalStatus :uuid />
{{/if}}
@ -38,8 +38,8 @@
:isStatusInOwnThread :uuid :visibility :replyShown
on:recalculateHeight />
{{#if replyShown}}
<StatusComposeBox :originalStatusId :uuid
:replyVisibility :visibility
<StatusComposeBox :originalStatusId :uuid :replyVisibility
:visibility :spoilerText
on:recalculateHeight />
{{/if}}
</article>
@ -171,6 +171,7 @@
originalAccount: (originalStatus) => originalStatus.account,
originalAccountId: (originalAccount) => originalAccount.id,
visibility: (originalStatus) => originalStatus.visibility,
spoilerText: (originalStatus) => originalStatus.spoiler_text,
uuid: ($currentInstance, timelineType, timelineValue, notificationId, statusId) => {
return `${$currentInstance}/${timelineType}/${timelineValue}/${notificationId || ''}/${statusId}`
},

View file

@ -4,6 +4,7 @@
autoFocus="true"
hideBottomBorder="true"
replyVisibility="{{visibility}}"
replySpoiler="{{spoilerText}}"
on:postedStatus="onPostedStatus()"
/>
</div>