mirror of https://github.com/tooot-app/app
When replying to CW content, CW will be added
This commit is contained in:
parent
f3fa6bc662
commit
4eea2bf58c
|
@ -1,4 +1,3 @@
|
|||
import apiInstance from '@api/instance'
|
||||
import { toast, toastConfig } from '@components/toast'
|
||||
import {
|
||||
NavigationContainer,
|
||||
|
@ -9,6 +8,7 @@ import ScreenAnnouncements from '@screens/Announcements'
|
|||
import ScreenCompose from '@screens/Compose'
|
||||
import ScreenImagesViewer from '@screens/ImagesViewer'
|
||||
import ScreenTabs from '@screens/Tabs'
|
||||
import { useAnnouncementQuery } from '@utils/queryHooks/announcement'
|
||||
import { updatePreviousTab } from '@utils/slices/contextsSlice'
|
||||
import { updateAccountPreferences } from '@utils/slices/instances/updateAccountPreferences'
|
||||
import { getInstanceActive } from '@utils/slices/instancesSlice'
|
||||
|
@ -117,28 +117,28 @@ const Screens: React.FC<Props> = ({ localCorrupt }) => {
|
|||
}, [localCorrupt])
|
||||
|
||||
// On launch check if there is any unread announcements
|
||||
useEffect(() => {
|
||||
instanceActive !== -1 &&
|
||||
apiInstance<Mastodon.Announcement[]>({
|
||||
method: 'get',
|
||||
url: `announcements`
|
||||
})
|
||||
.then(res => {
|
||||
if (res.body.filter(announcement => !announcement.read).length) {
|
||||
navigationRef.current?.navigate('Screen-Announcements', {
|
||||
showAll: false
|
||||
})
|
||||
}
|
||||
})
|
||||
.catch(() => {})
|
||||
}, [])
|
||||
useAnnouncementQuery({
|
||||
showAll: false,
|
||||
options: {
|
||||
notifyOnChangeProps: [],
|
||||
select: announcements =>
|
||||
announcements.filter(announcement => !announcement.read),
|
||||
onSuccess: data => {
|
||||
if (data.length) {
|
||||
navigationRef.current?.navigate('Screen-Announcements', {
|
||||
showAll: false
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
// Lazily update users's preferences, for e.g. composing default visibility
|
||||
useEffect(() => {
|
||||
if (instanceActive !== -1) {
|
||||
dispatch(updateAccountPreferences())
|
||||
}
|
||||
}, [])
|
||||
}, [instanceActive])
|
||||
|
||||
// Callbacks
|
||||
const navigationContainerOnReady = useCallback(
|
||||
|
|
|
@ -28,7 +28,8 @@ const HeaderCenter = React.memo(
|
|||
|
||||
const styles = StyleSheet.create({
|
||||
text: {
|
||||
...StyleConstants.FontStyle.M
|
||||
fontSize: 18,
|
||||
fontWeight: StyleConstants.Font.Weight.Bold
|
||||
}
|
||||
})
|
||||
|
||||
|
|
|
@ -204,13 +204,13 @@ const ScreenAnnouncements: React.FC<ScreenAnnouncementsProp> = ({
|
|||
style={styles.base}
|
||||
reducedTransparencyFallbackColor={theme.background}
|
||||
>
|
||||
<SafeAreaView style={styles.base} edges={['bottom']}>
|
||||
<SafeAreaView style={styles.base}>
|
||||
<View
|
||||
style={{
|
||||
flex: 1,
|
||||
flexDirection: 'row',
|
||||
justifyContent: 'space-between',
|
||||
alignItems: 'center'
|
||||
alignItems: 'center',
|
||||
flexBasis: 44
|
||||
}}
|
||||
>
|
||||
<HeaderLeft
|
||||
|
@ -236,7 +236,7 @@ const ScreenAnnouncements: React.FC<ScreenAnnouncementsProp> = ({
|
|||
onMomentumScrollEnd={onMomentumScrollEnd}
|
||||
ListEmptyComponent={ListEmptyComponent}
|
||||
/>
|
||||
<View style={[styles.indicators]}>
|
||||
<View style={styles.indicators}>
|
||||
{query.data && query.data.length > 1 ? (
|
||||
<>
|
||||
{query.data.map((d, i) => (
|
||||
|
|
|
@ -145,6 +145,23 @@ const ScreenCompose: React.FC<ScreenComposeProp> = ({
|
|||
})
|
||||
break
|
||||
case 'reply':
|
||||
const actualStatus =
|
||||
params.incomingStatus.reblog || params.incomingStatus
|
||||
if (actualStatus.spoiler_text) {
|
||||
formatText({
|
||||
textInput: 'spoiler',
|
||||
composeDispatch,
|
||||
content: actualStatus.spoiler_text,
|
||||
disableDebounce: true
|
||||
})
|
||||
}
|
||||
formatText({
|
||||
textInput: 'text',
|
||||
composeDispatch,
|
||||
content: params.accts.map(acct => `@${acct}`).join(' ') + ' ',
|
||||
disableDebounce: true
|
||||
})
|
||||
break
|
||||
case 'conversation':
|
||||
formatText({
|
||||
textInput: 'text',
|
||||
|
|
|
@ -39,7 +39,7 @@ const composeParseState = (
|
|||
}),
|
||||
visibility:
|
||||
params.incomingStatus.visibility ||
|
||||
getInstanceAccount(store.getState()).preferences[
|
||||
getInstanceAccount(store.getState())?.preferences[
|
||||
'posting:default:visibility'
|
||||
] ||
|
||||
'public',
|
||||
|
@ -53,6 +53,9 @@ const composeParseState = (
|
|||
...composeInitialState,
|
||||
dirty: true,
|
||||
timestamp: Date.now(),
|
||||
...(actualStatus.spoiler_text && {
|
||||
spoiler: { ...composeInitialState.spoiler, active: true }
|
||||
}),
|
||||
visibility: actualStatus.visibility,
|
||||
visibilityLock: actualStatus.visibility === 'direct',
|
||||
replyToStatus: actualStatus
|
||||
|
|
|
@ -302,7 +302,7 @@ export const getInstanceMaxTootChar = ({
|
|||
instances: { instances }
|
||||
}: RootState) => {
|
||||
const instanceActive = findInstanceActive(instances)
|
||||
return instanceActive !== -1 ? instances[instanceActive].max_toot_chars : null
|
||||
return instanceActive !== -1 ? instances[instanceActive].max_toot_chars : 500
|
||||
}
|
||||
|
||||
export const getInstanceAccount = ({ instances: { instances } }: RootState) => {
|
||||
|
|
Loading…
Reference in New Issue