[IMPROVEMENT] Add "Allow_Save_Media_to_Gallery" setting (#2459)

* [IMPROVEMENT] Add "Allow_Save_Media_to_Gallery" setting

* Default true for old servers
This commit is contained in:
Diego Mello 2020-09-15 10:34:49 -03:00 committed by GitHub
parent c61076c983
commit b30421d5c4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 5 deletions

View File

@ -184,5 +184,8 @@ export default {
}, },
Force_Screen_Lock_After: { Force_Screen_Lock_After: {
type: 'valueAsNumber' type: 'valueAsNumber'
},
Allow_Save_Media_to_Gallery: {
type: 'valueAsBoolean'
} }
}; };

View File

@ -42,7 +42,8 @@ class AttachmentView extends React.Component {
user: PropTypes.shape({ user: PropTypes.shape({
id: PropTypes.string, id: PropTypes.string,
token: PropTypes.string token: PropTypes.string
}) }),
Allow_Save_Media_to_Gallery: PropTypes.bool
} }
constructor(props) { constructor(props) {
@ -68,7 +69,9 @@ class AttachmentView extends React.Component {
} }
setHeader = () => { setHeader = () => {
const { route, navigation, theme } = this.props; const {
route, navigation, theme, Allow_Save_Media_to_Gallery
} = this.props;
const attachment = route.params?.attachment; const attachment = route.params?.attachment;
let { title } = attachment; let { title } = attachment;
try { try {
@ -79,10 +82,14 @@ class AttachmentView extends React.Component {
const options = { const options = {
title, title,
headerLeft: () => <CloseModalButton testID='close-attachment-view' navigation={navigation} buttonStyle={{ color: themes[theme].previewTintColor }} />, headerLeft: () => <CloseModalButton testID='close-attachment-view' navigation={navigation} buttonStyle={{ color: themes[theme].previewTintColor }} />,
headerRight: () => <SaveButton testID='save-image' onPress={this.handleSave} buttonStyle={{ color: themes[theme].previewTintColor }} />, headerRight: () => (
Allow_Save_Media_to_Gallery
? <SaveButton testID='save-image' onPress={this.handleSave} buttonStyle={{ color: themes[theme].previewTintColor }} />
: null
),
headerBackground: () => <View style={{ flex: 1, backgroundColor: themes[theme].previewBackground }} />, headerBackground: () => <View style={{ flex: 1, backgroundColor: themes[theme].previewBackground }} />,
headerTintColor: themes[theme].previewTintColor, headerTintColor: themes[theme].previewTintColor,
headerTitleStyle: { color: themes[theme].previewTintColor } headerTitleStyle: { color: themes[theme].previewTintColor, marginHorizontal: 10 }
}; };
navigation.setOptions(options); navigation.setOptions(options);
} }
@ -180,7 +187,8 @@ class AttachmentView extends React.Component {
const mapStateToProps = state => ({ const mapStateToProps = state => ({
baseUrl: state.server.server, baseUrl: state.server.server,
user: getUserSelector(state) user: getUserSelector(state),
Allow_Save_Media_to_Gallery: state.settings.Allow_Save_Media_to_Gallery ?? true
}); });
export default connect(mapStateToProps)(withTheme(withDimensions(withSafeAreaInsets(AttachmentView)))); export default connect(mapStateToProps)(withTheme(withDimensions(withSafeAreaInsets(AttachmentView))));