From f5a01ff1542f83f70be691566e68158fdc19cb59 Mon Sep 17 00:00:00 2001 From: Mo Bitar Date: Fri, 4 Jan 2019 19:35:21 -0600 Subject: [PATCH] Remove RNMail in favor of Share; doesn't work on Android however --- package-lock.json | 6 ++--- package.json | 2 +- src/containers/account/OptionsSection.js | 2 +- src/screens/Settings.js | 33 +++++++----------------- 4 files changed, 14 insertions(+), 29 deletions(-) diff --git a/package-lock.json b/package-lock.json index d5c0f6f9..0fb1fcdf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -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", diff --git a/package.json b/package.json index 3960c6e7..df89d72a 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/containers/account/OptionsSection.js b/src/containers/account/OptionsSection.js index 6b0c1947..ba73cf50 100644 --- a/src/containers/account/OptionsSection.js +++ b/src/containers/account/OptionsSection.js @@ -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 { diff --git a/src/screens/Settings.js b/src/screens/Settings.js index c2d799ae..2257d2a0 100644 --- a/src/screens/Settings.js +++ b/src/screens/Settings.js @@ -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); + }) + }) }); }