mirror of
https://github.com/standardnotes/mobile.git
synced 2026-01-27 09:08:13 -05:00
Remove RNMail in favor of Share; doesn't work on Android however
This commit is contained in:
6
package-lock.json
generated
6
package-lock.json
generated
@@ -11769,9 +11769,9 @@
|
||||
"integrity": "sha1-ATl5IuX2Ls8whFUiyVxP4dJefU4="
|
||||
},
|
||||
"standard-file-js": {
|
||||
"version": "0.3.24",
|
||||
"resolved": "https://registry.npmjs.org/standard-file-js/-/standard-file-js-0.3.24.tgz",
|
||||
"integrity": "sha512-LGqhfvnskr0IaH7rM28bZEI+8xJZectXdtcXPPfSdv46kIq9QjqcoqJnPNfqBHWwHu8L8grPaUBK36Q7ALQBwQ=="
|
||||
"version": "0.3.27",
|
||||
"resolved": "https://registry.npmjs.org/standard-file-js/-/standard-file-js-0.3.27.tgz",
|
||||
"integrity": "sha512-zqMBVWiquS/40cEchNXSvuXovuzoXgNR9/UsJtXJ748zN2Ezpy7WIA3kmXp67aROBvP6vopRJjPkBe+6JkvTzA=="
|
||||
},
|
||||
"static-extend": {
|
||||
"version": "0.1.2",
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
"react-navigation-header-buttons": "^2.1.1",
|
||||
"regenerator": "^0.13.3",
|
||||
"sn-models": "0.1.8",
|
||||
"standard-file-js": "0.3.24"
|
||||
"standard-file-js": "0.3.27"
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-jest": "^23.6.0",
|
||||
|
||||
@@ -9,7 +9,7 @@ import SectionedTableCell from "../../components/SectionedTableCell";
|
||||
import SectionedAccessoryTableCell from "../../components/SectionedAccessoryTableCell";
|
||||
import SectionedOptionsTableCell from "../../components/SectionedOptionsTableCell";
|
||||
|
||||
import {moment} from "../../lib/moment"
|
||||
import moment from "@Lib/moment"
|
||||
|
||||
export default class OptionsSection extends Component {
|
||||
|
||||
|
||||
@@ -29,7 +29,6 @@ import ApplicationState from "@Lib/ApplicationState"
|
||||
import StyleKit from "../style/StyleKit"
|
||||
|
||||
var base64 = require('base-64');
|
||||
var Mailer = require('NativeModules').RNMail;
|
||||
|
||||
export default class Settings extends Abstract {
|
||||
|
||||
@@ -272,7 +271,6 @@ export default class Settings extends Abstract {
|
||||
this.handlePrivilegedAction(true, SFPrivilegesManager.ActionManageBackups, async () => {
|
||||
let customCallback = (success) => {
|
||||
if(success) {
|
||||
// UserPrefsManager.get().clearLastExportDate();
|
||||
var date = new Date();
|
||||
this.setState({lastExportDate: date});
|
||||
UserPrefsManager.get().setLastExportDate(date);
|
||||
@@ -305,31 +303,18 @@ export default class Settings extends Abstract {
|
||||
}
|
||||
|
||||
var jsonString = JSON.stringify(data, null, 2 /* pretty print */);
|
||||
var stringData = ApplicationState.isIOS ? jsonString : base64.encode(unescape(encodeURIComponent(jsonString)))
|
||||
var fileType = ApplicationState.isAndroid ? ".json" : "json"; // Android creates a tmp file and expects dot with extension
|
||||
|
||||
var calledCallback = false;
|
||||
|
||||
Mailer.mail({
|
||||
subject: 'Standard Notes Backup',
|
||||
recipients: [''],
|
||||
body: '',
|
||||
isHTML: true,
|
||||
attachment: { data: stringData, type: fileType, name: encrypted ? "SN-Encrypted-Backup" : 'SN-Decrypted-Backup' }
|
||||
}, (error, event) => {
|
||||
customCallback(false);
|
||||
calledCallback = true;
|
||||
if(error) {
|
||||
Alert.alert('Error', 'Unable to send email.');
|
||||
}
|
||||
});
|
||||
|
||||
// On Android the Mailer callback event isn't always triggered.
|
||||
setTimeout(function () {
|
||||
if(!calledCallback) {
|
||||
customCallback(true);
|
||||
}
|
||||
}, 2500);
|
||||
ApplicationState.get().performActionWithoutStateChangeImpact(() => {
|
||||
Share.share({
|
||||
title: encrypted ? "SN-Encrypted-Backup" : 'SN-Decrypted-Backup',
|
||||
message: jsonString,
|
||||
}).then((event) => {
|
||||
console.log("Result", event);
|
||||
customCallback(event != Share.dismissedAction);
|
||||
})
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user