diff --git a/src/screens/Compose.tsx b/src/screens/Compose.tsx index e647e019..31bc53ee 100644 --- a/src/screens/Compose.tsx +++ b/src/screens/Compose.tsx @@ -88,6 +88,14 @@ const ScreenCompose: React.FC = ({ return { ...composeInitialState, timestamp: Date.now(), + attachments: { + ...composeInitialState.attachments, + sensitive: + localAccount?.preferences && + localAccount?.preferences['posting:default:sensitive'] + ? localAccount?.preferences['posting:default:sensitive'] + : false + }, visibility: localAccount?.preferences && localAccount.preferences['posting:default:visibility'] diff --git a/src/screens/Compose/utils/initialState.ts b/src/screens/Compose/utils/initialState.ts index d340e37f..85306b3b 100644 --- a/src/screens/Compose/utils/initialState.ts +++ b/src/screens/Compose/utils/initialState.ts @@ -31,7 +31,10 @@ const composeInitialState: Omit = { multiple: false, expire: '86400' }, - attachments: { sensitive: false, uploads: [] }, + attachments: { + sensitive: false, + uploads: [] + }, visibility: 'public', visibilityLock: false, replyToStatus: undefined, diff --git a/src/screens/Tabs/Me/Profile/Root.tsx b/src/screens/Tabs/Me/Profile/Root.tsx index 38cf2547..72da7ef7 100644 --- a/src/screens/Tabs/Me/Profile/Root.tsx +++ b/src/screens/Tabs/Me/Profile/Root.tsx @@ -3,11 +3,13 @@ import { displayMessage } from '@components/Message' import { useActionSheet } from '@expo/react-native-action-sheet' import { StackScreenProps } from '@react-navigation/stack' import { useProfileMutation, useProfileQuery } from '@utils/queryHooks/profile' +import { updateAccountPreferences } from '@utils/slices/instances/updateAccountPreferences' import { useTheme } from '@utils/styles/ThemeManager' import React, { RefObject, useCallback } from 'react' import { useTranslation } from 'react-i18next' import FlashMessage from 'react-native-flash-message' import { ScrollView } from 'react-native-gesture-handler' +import { useDispatch } from 'react-redux' import ProfileAvatarHeader from './Root/AvatarHeader' const TabMeProfileRoot: React.FC { showActionSheetWithOptions( @@ -37,8 +40,9 @@ const TabMeProfileRoot: React.FC { switch (buttonIndex) { case 0: - mutateAsync({ type: 'source[privacy]', data: 'public' }).catch( - err => + mutateAsync({ type: 'source[privacy]', data: 'public' }) + .then(() => dispatch(updateAccountPreferences())) + .catch(err => displayMessage({ ref: messageRef, message: t('me.profile.feedback.failed', { @@ -48,11 +52,12 @@ const TabMeProfileRoot: React.FC + mutateAsync({ type: 'source[privacy]', data: 'unlisted' }) + .then(() => dispatch(updateAccountPreferences())) + .catch(err => displayMessage({ ref: messageRef, message: t('me.profile.feedback.failed', { @@ -62,11 +67,12 @@ const TabMeProfileRoot: React.FC + mutateAsync({ type: 'source[privacy]', data: 'private' }) + .then(() => dispatch(updateAccountPreferences())) + .catch(err => displayMessage({ ref: messageRef, message: t('me.profile.feedback.failed', { @@ -76,7 +82,7 @@ const TabMeProfileRoot: React.FC { if (data?.source.sensitive === undefined) { - mutateAsync({ type: 'source[sensitive]', data: true }).catch(err => - displayMessage({ - ref: messageRef, - message: t('me.profile.feedback.failed', { - type: t('me.profile.root.sensitive.title') - }), - ...(err && { description: err }), - mode, - type: 'error' - }) - ) + mutateAsync({ type: 'source[sensitive]', data: true }) + .then(() => dispatch(updateAccountPreferences())) + .catch(err => + displayMessage({ + ref: messageRef, + message: t('me.profile.feedback.failed', { + type: t('me.profile.root.sensitive.title') + }), + ...(err && { description: err }), + mode, + type: 'error' + }) + ) } else { mutateAsync({ type: 'source[sensitive]', data: !data.source.sensitive - }).catch(err => - displayMessage({ - ref: messageRef, - message: t('me.profile.feedback.failed', { - type: t('me.profile.root.sensitive.title') - }), - ...(err && { description: err }), - mode, - type: 'error' - }) - ) + }) + .then(() => dispatch(updateAccountPreferences())) + .catch(err => + displayMessage({ + ref: messageRef, + message: t('me.profile.feedback.failed', { + type: t('me.profile.root.sensitive.title') + }), + ...(err && { description: err }), + mode, + type: 'error' + }) + ) } }, [data?.source.sensitive])