Changeset View
Changeset View
Standalone View
Standalone View
native/utils/edit-messages-utils.js
// @flow | // @flow | ||||
import * as React from 'react'; | |||||
import Alert from 'react-native/Libraries/Alert/Alert.js'; | import Alert from 'react-native/Libraries/Alert/Alert.js'; | ||||
import { FeatureFlagsContext } from '../components/feature-flags-provider.react.js'; | |||||
function useShouldRenderEditButton(): boolean { | |||||
const { configuration: featureFlagConfig } = | |||||
React.useContext(FeatureFlagsContext); | |||||
return !!featureFlagConfig['EDIT_BUTTON_DISPLAY']; | |||||
} | |||||
function exitEditAlert(onDiscard: () => void): void { | function exitEditAlert(onDiscard: () => void): void { | ||||
Alert.alert( | Alert.alert( | ||||
'Discard changes?', | 'Discard changes?', | ||||
'You have unsaved changes which will be discarded if you navigate away.', | 'You have unsaved changes which will be discarded if you navigate away.', | ||||
[ | [ | ||||
{ | { | ||||
text: 'Continue editing', | text: 'Continue editing', | ||||
style: 'cancel', | style: 'cancel', | ||||
}, | }, | ||||
{ | { | ||||
text: 'Discard edit', | text: 'Discard edit', | ||||
style: 'destructive', | style: 'destructive', | ||||
onPress: () => { | onPress: () => { | ||||
onDiscard(); | onDiscard(); | ||||
}, | }, | ||||
}, | }, | ||||
], | ], | ||||
); | ); | ||||
} | } | ||||
export { useShouldRenderEditButton, exitEditAlert }; | export { exitEditAlert }; |