mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-19 03:11:38 +03:00
created send feedback feature
This commit is contained in:
parent
9d35e81a37
commit
fab90fe312
@ -66,11 +66,15 @@
|
||||
"pincode": "PIN code",
|
||||
"reset": "Reset",
|
||||
"nsfw_content": "NSFW Content",
|
||||
"send_feedback": "Send Feedback",
|
||||
"send": "Send",
|
||||
"nsfw": {
|
||||
"always_show": "Always show",
|
||||
"always_hide": "Always hide",
|
||||
"always_warn": "Always warn"
|
||||
}
|
||||
},
|
||||
"feedback_success": "Email successfully open",
|
||||
"feedback_fail": "Email client could not open"
|
||||
},
|
||||
"voters": {
|
||||
"voters_info": "Voters Info",
|
||||
|
@ -4,6 +4,7 @@ import { connect } from 'react-redux';
|
||||
import AppCenter from 'appcenter';
|
||||
import Push from 'appcenter-push';
|
||||
import { Client } from 'dsteem';
|
||||
import VersionNumber from 'react-native-version-number';
|
||||
|
||||
// Realm
|
||||
import {
|
||||
@ -36,6 +37,7 @@ import { VALUE as CURRENCY_VALUE } from '../../../constants/options/currency';
|
||||
import { VALUE as LANGUAGE_VALUE } from '../../../constants/options/language';
|
||||
|
||||
// Utilities
|
||||
import { sendEmail } from '../../../utils/sendEmail';
|
||||
|
||||
// Component
|
||||
import SettingsScreen from '../screen/settingsScreen';
|
||||
@ -86,6 +88,10 @@ class SettingsContainer extends Component {
|
||||
setNsfw2DB(action);
|
||||
break;
|
||||
|
||||
case 'feedback':
|
||||
this._handleSendFeedback();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -216,6 +222,36 @@ class SettingsContainer extends Component {
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
_handleSendFeedback = async () => {
|
||||
const { dispatch, intl } = this.props;
|
||||
let message;
|
||||
|
||||
await sendEmail(
|
||||
'bug@esteem.app',
|
||||
'Feedback/Bug report',
|
||||
`Write your message here!
|
||||
App version: ${VersionNumber.buildVersion}
|
||||
Platform: ${Platform.OS === 'ios' ? 'IOS' : 'Android'}
|
||||
Device: ${DeviceInfo.getDeviceName()}`,
|
||||
)
|
||||
.then(() => {
|
||||
message = 'settings.feedback_success';
|
||||
})
|
||||
.catch(() => {
|
||||
message = 'settings.feedback_fail';
|
||||
});
|
||||
|
||||
if (message) {
|
||||
dispatch(
|
||||
toastNotification(
|
||||
intl.formatMessage({
|
||||
id: message,
|
||||
}),
|
||||
),
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
render() {
|
||||
const { serverList } = this.state;
|
||||
|
@ -1,4 +1,4 @@
|
||||
import React, { PureComponent } from 'react';
|
||||
import React, { PureComponent, Fragment } from 'react';
|
||||
import { ScrollView, View } from 'react-native';
|
||||
import { injectIntl } from 'react-intl';
|
||||
|
||||
@ -116,17 +116,30 @@ class SettingsScreen extends PureComponent {
|
||||
handleOnChange={handleOnChange}
|
||||
/>
|
||||
{!!isLoggedIn && (
|
||||
<SettingsItem
|
||||
title={intl.formatMessage({
|
||||
id: 'settings.pincode',
|
||||
})}
|
||||
text={intl.formatMessage({
|
||||
id: 'settings.reset',
|
||||
})}
|
||||
type="button"
|
||||
actionType="pincode"
|
||||
handleOnChange={handleOnChange}
|
||||
/>
|
||||
<Fragment>
|
||||
<SettingsItem
|
||||
title={intl.formatMessage({
|
||||
id: 'settings.pincode',
|
||||
})}
|
||||
text={intl.formatMessage({
|
||||
id: 'settings.reset',
|
||||
})}
|
||||
type="button"
|
||||
actionType="pincode"
|
||||
handleOnChange={handleOnChange}
|
||||
/>
|
||||
<SettingsItem
|
||||
title={intl.formatMessage({
|
||||
id: 'settings.send_feedback',
|
||||
})}
|
||||
text={intl.formatMessage({
|
||||
id: 'settings.send',
|
||||
})}
|
||||
type="button"
|
||||
actionType="feedback"
|
||||
handleOnChange={handleOnChange}
|
||||
/>
|
||||
</Fragment>
|
||||
)}
|
||||
</ScrollView>
|
||||
</View>
|
||||
|
27
src/utils/sendEmail.js
Normal file
27
src/utils/sendEmail.js
Normal file
@ -0,0 +1,27 @@
|
||||
import { Linking } from 'react-native';
|
||||
import qs from 'qs';
|
||||
|
||||
export const sendEmail = async (to, subject, body, options = {}) => {
|
||||
const { cc, bcc } = options;
|
||||
|
||||
let url = `mailto:${to}`;
|
||||
|
||||
const query = qs.stringify({
|
||||
subject,
|
||||
body,
|
||||
cc,
|
||||
bcc,
|
||||
});
|
||||
|
||||
if (query.length) {
|
||||
url += `?${query}`;
|
||||
}
|
||||
|
||||
const canOpen = await Linking.canOpenURL(url);
|
||||
|
||||
if (!canOpen) {
|
||||
throw new Error('Provided URL can not be handled');
|
||||
}
|
||||
|
||||
return Linking.openURL(url);
|
||||
};
|
Loading…
Reference in New Issue
Block a user