mirror of https://github.com/tooot-app/app
Fixed #38
This commit is contained in:
parent
8a49c92c79
commit
4319e83bb9
|
@ -3,6 +3,36 @@ import { getInstanceAccount } from '@utils/slices/instancesSlice'
|
||||||
import composeInitialState from './initialState'
|
import composeInitialState from './initialState'
|
||||||
import { ComposeState } from './types'
|
import { ComposeState } from './types'
|
||||||
|
|
||||||
|
const assignVisibility = (
|
||||||
|
target: ComposeState['visibility']
|
||||||
|
): Pick<ComposeState, 'visibility' | 'visibilityLock'> => {
|
||||||
|
const accountPreference = getInstanceAccount(store.getState())?.preferences[
|
||||||
|
'posting:default:visibility'
|
||||||
|
]
|
||||||
|
|
||||||
|
switch (target) {
|
||||||
|
case 'direct':
|
||||||
|
return { visibility: 'direct', visibilityLock: true }
|
||||||
|
case 'private':
|
||||||
|
return { visibility: 'private', visibilityLock: false }
|
||||||
|
case 'unlisted':
|
||||||
|
if (accountPreference === 'private') {
|
||||||
|
return { visibility: 'private', visibilityLock: false }
|
||||||
|
} else {
|
||||||
|
return { visibility: 'unlisted', visibilityLock: false }
|
||||||
|
}
|
||||||
|
case 'public':
|
||||||
|
switch (accountPreference) {
|
||||||
|
case 'private':
|
||||||
|
return { visibility: 'private', visibilityLock: false }
|
||||||
|
case 'unlisted':
|
||||||
|
return { visibility: 'unlisted', visibilityLock: false }
|
||||||
|
default:
|
||||||
|
return { visibility: 'public', visibilityLock: false }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const composeParseState = (
|
const composeParseState = (
|
||||||
params: NonNullable<Nav.RootStackParamList['Screen-Compose']>
|
params: NonNullable<Nav.RootStackParamList['Screen-Compose']>
|
||||||
): ComposeState => {
|
): ComposeState => {
|
||||||
|
@ -37,15 +67,7 @@ const composeParseState = (
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
visibility:
|
...assignVisibility(params.incomingStatus.visibility),
|
||||||
params.incomingStatus.visibility ||
|
|
||||||
getInstanceAccount(store.getState())?.preferences[
|
|
||||||
'posting:default:visibility'
|
|
||||||
] ||
|
|
||||||
'public',
|
|
||||||
...(params.incomingStatus.visibility === 'direct' && {
|
|
||||||
visibilityLock: true
|
|
||||||
}),
|
|
||||||
...(params.replyToStatus && { replyToStatus: params.replyToStatus })
|
...(params.replyToStatus && { replyToStatus: params.replyToStatus })
|
||||||
}
|
}
|
||||||
case 'reply':
|
case 'reply':
|
||||||
|
@ -57,8 +79,7 @@ const composeParseState = (
|
||||||
...(actualStatus.spoiler_text && {
|
...(actualStatus.spoiler_text && {
|
||||||
spoiler: { ...composeInitialState.spoiler, active: true }
|
spoiler: { ...composeInitialState.spoiler, active: true }
|
||||||
}),
|
}),
|
||||||
visibility: actualStatus.visibility,
|
...assignVisibility(actualStatus.visibility),
|
||||||
visibilityLock: actualStatus.visibility === 'direct',
|
|
||||||
replyToStatus: actualStatus
|
replyToStatus: actualStatus
|
||||||
}
|
}
|
||||||
case 'conversation':
|
case 'conversation':
|
||||||
|
@ -66,8 +87,7 @@ const composeParseState = (
|
||||||
...composeInitialState,
|
...composeInitialState,
|
||||||
dirty: true,
|
dirty: true,
|
||||||
timestamp: Date.now(),
|
timestamp: Date.now(),
|
||||||
visibility: 'direct',
|
...assignVisibility('direct')
|
||||||
visibilityLock: true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue