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 let endIndex = selectionStart
await insertUsername(realm, account.acct, startIndex, endIndex) 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 { CHAR_LIMIT, POST_PRIVACY_OPTIONS } from '../../_static/statuses'
import { store } from '../../_store/store' import { store } from '../../_store/store'
import { slide } from 'svelte-transitions' import { slide } from 'svelte-transitions'
import { postStatus, insertHandleForReply } from '../../_actions/compose' import { postStatus, insertHandleForReply, setReplySpoiler } from '../../_actions/compose'
import { importDialogs } from '../../_utils/asyncModules' import { importDialogs } from '../../_utils/asyncModules'
import { classname } from '../../_utils/classname' import { classname } from '../../_utils/classname'
@ -119,6 +119,12 @@
insertHandleForReply(realm) 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 => { this.observe('postedStatusForRealm', postedStatusForRealm => {
if (postedStatusForRealm !== realm) { if (postedStatusForRealm !== realm) {
return return

View File

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

View File

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