forked from cybrespace/pinafore
fix default post privacy on replies
This commit is contained in:
parent
e0345ad750
commit
bd183c9b37
|
@ -77,3 +77,21 @@ export function setReplySpoiler (realm, spoiler) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const PRIVACY_LEVEL = {
|
||||||
|
'direct': 1,
|
||||||
|
'private': 2,
|
||||||
|
'unlisted': 3,
|
||||||
|
'public': 4
|
||||||
|
}
|
||||||
|
|
||||||
|
export function setReplyVisibility (realm, replyVisibility) {
|
||||||
|
// return the most private between the user's preferred default privacy
|
||||||
|
// and the privacy of the status they're replying to
|
||||||
|
let verifyCredentials = store.get('currentVerifyCredentials')
|
||||||
|
let defaultVisibility = verifyCredentials.source.privacy
|
||||||
|
let visibility = PRIVACY_LEVEL[replyVisibility] < PRIVACY_LEVEL[defaultVisibility]
|
||||||
|
? replyVisibility
|
||||||
|
: defaultVisibility
|
||||||
|
store.setComposeData(realm, {postPrivacy: visibility})
|
||||||
|
}
|
||||||
|
|
|
@ -98,17 +98,10 @@
|
||||||
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, setReplySpoiler } from '../../_actions/compose'
|
import { postStatus, insertHandleForReply, setReplySpoiler, setReplyVisibility } from '../../_actions/compose'
|
||||||
import { importDialogs } from '../../_utils/asyncModules'
|
import { importDialogs } from '../../_utils/asyncModules'
|
||||||
import { classname } from '../../_utils/classname'
|
import { classname } from '../../_utils/classname'
|
||||||
|
|
||||||
const PRIVACY_LEVEL = {
|
|
||||||
'direct': 1,
|
|
||||||
'private': 2,
|
|
||||||
'unlisted': 3,
|
|
||||||
'public': 4
|
|
||||||
}
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
oncreate() {
|
oncreate() {
|
||||||
let realm = this.get('realm')
|
let realm = this.get('realm')
|
||||||
|
@ -125,6 +118,12 @@
|
||||||
setReplySpoiler(realm, replySpoiler)
|
setReplySpoiler(realm, replySpoiler)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let replyVisibility = this.get('replyVisibility')
|
||||||
|
if (replyVisibility) {
|
||||||
|
// make sure the visibility is consistent with the replied-to status
|
||||||
|
setReplyVisibility(realm, replyVisibility)
|
||||||
|
}
|
||||||
|
|
||||||
this.observe('postedStatusForRealm', postedStatusForRealm => {
|
this.observe('postedStatusForRealm', postedStatusForRealm => {
|
||||||
if (postedStatusForRealm !== realm) {
|
if (postedStatusForRealm !== realm) {
|
||||||
return
|
return
|
||||||
|
@ -164,16 +163,7 @@
|
||||||
text: (composeData) => composeData.text || '',
|
text: (composeData) => composeData.text || '',
|
||||||
media: (composeData) => composeData.media || [],
|
media: (composeData) => composeData.media || [],
|
||||||
postPrivacy: (postPrivacyKey) => POST_PRIVACY_OPTIONS.find(_ => _.key === postPrivacyKey),
|
postPrivacy: (postPrivacyKey) => POST_PRIVACY_OPTIONS.find(_ => _.key === postPrivacyKey),
|
||||||
defaultPostPrivacyKey: ($currentVerifyCredentials, replyVisibility) => {
|
defaultPostPrivacyKey: ($currentVerifyCredentials) => $currentVerifyCredentials.source.privacy,
|
||||||
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,
|
postPrivacyKey: (composeData, defaultPostPrivacyKey) => composeData.postPrivacy || defaultPostPrivacyKey,
|
||||||
textLength: (text) => measureText(text),
|
textLength: (text) => measureText(text),
|
||||||
contentWarningLength: (contentWarning) => measureText(contentWarning),
|
contentWarningLength: (contentWarning) => measureText(contentWarning),
|
||||||
|
|
Loading…
Reference in New Issue