fix post privacy for replies
This commit is contained in:
parent
91402d06fc
commit
f9993cac35
|
@ -102,6 +102,13 @@
|
|||
import { importDialogs } from '../../_utils/asyncModules'
|
||||
import { classname } from '../../_utils/classname'
|
||||
|
||||
const PRIVACY_LEVEL = {
|
||||
'direct': 1,
|
||||
'private': 2,
|
||||
'unlisted': 3,
|
||||
'public': 4
|
||||
}
|
||||
|
||||
export default {
|
||||
oncreate() {
|
||||
let realm = this.get('realm')
|
||||
|
@ -156,7 +163,16 @@
|
|||
text: (composeData) => composeData.text || '',
|
||||
media: (composeData) => composeData.media || [],
|
||||
postPrivacy: (postPrivacyKey) => POST_PRIVACY_OPTIONS.find(_ => _.key === postPrivacyKey),
|
||||
defaultPostPrivacyKey: ($currentVerifyCredentials) => $currentVerifyCredentials.source.privacy,
|
||||
defaultPostPrivacyKey: ($currentVerifyCredentials, replyVisibility) => {
|
||||
let defaultVisibility = $currentVerifyCredentials.source.privacy
|
||||
// return the most private between the user's preferred default privacy
|
||||
// and the privacy of the status they're replying to
|
||||
if (replyVisibility &&
|
||||
PRIVACY_LEVEL[replyVisibility] < PRIVACY_LEVEL[defaultVisibility]) {
|
||||
return replyVisibility
|
||||
}
|
||||
return defaultVisibility
|
||||
},
|
||||
postPrivacyKey: (composeData, defaultPostPrivacyKey) => composeData.postPrivacy || defaultPostPrivacyKey,
|
||||
textLength: (text) => measureText(text),
|
||||
contentWarningLength: (contentWarning) => measureText(contentWarning),
|
||||
|
|
|
@ -38,7 +38,9 @@
|
|||
:isStatusInOwnThread :uuid :visibility :replyShown
|
||||
on:recalculateHeight />
|
||||
{{#if replyShown}}
|
||||
<StatusComposeBox :originalStatusId :uuid on:recalculateHeight />
|
||||
<StatusComposeBox :originalStatusId :uuid
|
||||
:replyVisibility :visibility
|
||||
on:recalculateHeight />
|
||||
{{/if}}
|
||||
</article>
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
size="slim"
|
||||
autoFocus="true"
|
||||
hideBottomBorder="true"
|
||||
replyVisibility="{{visibility}}"
|
||||
on:postedStatus="onPostedStatus()"
|
||||
/>
|
||||
</div>
|
||||
|
@ -44,7 +45,7 @@
|
|||
},
|
||||
store: () => store,
|
||||
computed: {
|
||||
composeData: ($currentComposeData, originalStatusId) => $currentComposeData[originalStatusId] || {},
|
||||
composeData: ($currentComposeData, originalStatusId) => $currentComposeData[originalStatusId] || {}
|
||||
},
|
||||
methods: {
|
||||
onPostedStatus() {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import {
|
||||
composeInput,
|
||||
getNthComposeReplyInput, getNthReplyButton,
|
||||
getNthComposeReplyInput, getNthPostPrivacyButton, getNthReplyButton,
|
||||
getNthStatus, getUrl, goBack, homeNavButton, notificationsNavButton
|
||||
} from '../utils'
|
||||
import { foobarRole } from '../roles'
|
||||
|
@ -34,3 +34,27 @@ test('replying to posts with mentions', async t => {
|
|||
.click(getNthReplyButton(0))
|
||||
.expect(getNthComposeReplyInput(0).value).eql('@ExternalLinks @admin @quux ')
|
||||
})
|
||||
|
||||
test('replies have same privacy as replied-to status by default', async t => {
|
||||
await t.useRole(foobarRole)
|
||||
.hover(getNthStatus(0))
|
||||
.hover(getNthStatus(1))
|
||||
.click(getNthReplyButton(1))
|
||||
.expect(getNthPostPrivacyButton(1).getAttribute('aria-label')).eql('Adjust privacy (currently Unlisted)')
|
||||
.click(getNthReplyButton(1))
|
||||
.hover(getNthStatus(2))
|
||||
.click(getNthReplyButton(2))
|
||||
.expect(getNthPostPrivacyButton(2).getAttribute('aria-label')).eql('Adjust privacy (currently Followers-only)')
|
||||
.click(getNthReplyButton(2))
|
||||
.hover(getNthStatus(3))
|
||||
.click(getNthReplyButton(3))
|
||||
.expect(getNthPostPrivacyButton(3).getAttribute('aria-label')).eql('Adjust privacy (currently Direct)')
|
||||
.click(getNthReplyButton(3))
|
||||
.hover(getNthStatus(4))
|
||||
.hover(getNthStatus(5))
|
||||
.hover(getNthStatus(6))
|
||||
.hover(getNthStatus(7))
|
||||
.click(getNthReplyButton(7))
|
||||
.expect(getNthPostPrivacyButton(7).getAttribute('aria-label')).eql('Adjust privacy (currently Public)')
|
||||
.click(getNthReplyButton(7))
|
||||
})
|
||||
|
|
|
@ -104,6 +104,10 @@ export function getNthComposeReplyButton (n) {
|
|||
return getNthStatus(n).find('.compose-box-button')
|
||||
}
|
||||
|
||||
export function getNthPostPrivacyButton (n) {
|
||||
return getNthStatus(n).find('.compose-box-toolbar button:nth-child(3)')
|
||||
}
|
||||
|
||||
export function getNthAutosuggestionResult (n) {
|
||||
return $(`.compose-autosuggest-list-item:nth-child(${n}) button`)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue